Now we've presented our
DiceViewController in three different
ways; programatically, using
a combination of code and Storyboard,
and entirely in Storyboard.
Recall that in the first solution,
the incoming instance of
DiceViewController is
manipulated directly.
The current view controller has a chance
to prepare the incoming view controller
and what did that preparation involve?
The roll view controller sets the two
dice values on the dice view controller.
When we use a segue the dice view
controller never makes an appearance in
our code because story board
hides the creation of the object.
So now we need a new hook to allow
communication between the two view
controllers.
The method we need is
called prepareForSegue.
All view controllers
inherit this method and
it's invoked right before
any segue is performed.
Its entire purpose is to allow
the current view controller to configure
the incoming object.
لقد قدمتم الآن
DiceViewController بثلاث طرق مختلفة
وهي برمجيًا
،وباستخدام مجموعة من التعليمات البرمجية ولوحة العمل
.وبشكل تام في لوحة العمل
،تذكروا هذا الحل الأول
حيث تتم معالجة المثيل الوارد لـ
DiceViewController مباشرة
.
ولدى وحدة التحكم في view الحالية فرصة
لإعداد وحدة التحكم في view الواردة
وما الذي اشتمل عليه الإعداد؟
تُعيّن rollviewcontroller
.قيمتي الزهر في diceviewcontroller
وعندما نستخدم التنقل السلس، لا يقوم diceviewcontroller
بعمل أي ظهور في
التعليمة البرمجية لأن لوحة العمل
.تُخفي إنشاء الكائن
ونحن بحاجة الآن إلى رابط جديد للسماح
بالاتصال بين وحدتي التحكم في
.view
والأسلوب الذي نحتاجه
.يسمى prepareForSegue
ترث جميع وحدات التحكم في view
هذا الأسلوب
ويتم استدعاؤه قبل
.تنفيذ أي تنقل سلس
فالغرض التام منه هو السماح
لوحدة التحكم في view الحالية بتكوين
.الكائن الوارد
Agora nós apresentamos nosso
DiceViewController de três maneiras
diferentes; programaticamente, usando
uma combinação de código e o Storyboard,
e inteiramente no Storyboard.
Lembre-se de que na primeira solução,
a instância de entrada de
DiceViewController é
manipulada diretamente.
O ViewController atual tem a chance
de preparar o ViewController de entrada,
e o que esta preparação envolveu?
O ViewController de rolagem define os dois
valores de dados no DiceViewController.
Quando usamos uma transição, o DiceViewController
nunca aparece no
nosso código, porque o storyboard
oculta a criação do objeto.
Portanto, agora precisamos de um novo gancho para
permitir a comunicação entre os dois
ViewControllers.
O método que precisamos é
chamado prepareForSegue.
Todos os ViewController
herdam esse método, e
ele é invocado logo antes
de qualquer transição ser executada.
O seu objetivo é permitir
que o ViewController atual configure o
objeto de entrada.