D
D
Dmitry2015-04-04 10:56:43
Objective-C
Dmitry, 2015-04-04 10:56:43

What is the best way to pass data between ViewControllers?

Good day everyone. I started trying to create applications for apple technology, and from the lack of information on the topic, questions arose regarding the "normality" of the methods used.
The task itself: to make an application for iOS using several ViewControllers on one storyboard. The first form contains a list of users, the second displays information about a specific user. The transition to the second screen occurs after pressing the button.
How I implemented it: I pulled out the button on the form, right-clicked the arrow on the second form and selected "show", and passed the data to the second form in the prepareForSegue function, checking the name of the segue (suddenly you need to add a transition to another form). Is this how the implementation of transitions was intended or is there some more "official" way?
I tried to connect a button press to a function where I manually created the desired controller and added it to the navigationController stack, but Xcode gives a warning, like you are acting somehow wrong.
Actually, how do you implement such functionality in your applications?
UPDATE
Here, the comrades said that it is better to do this through a button, but now the question is: what exactly does Xcode not like and how to remove this warning (if it needs to be removed at all)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman, 2015-04-04
@ubuntuman

added it to navigationController stack

You must remove the transition to another control on the storyboard. In the function that is called when the button is clicked, you are doing everything right, creating a controller, passing information to it and already choosing how to display it.
For example, to push an animation to a navigation controller you would call the method
To show the new controller as a modal, make the following call
AuthorizationVC *authVC = [AuthorizationVC new];
// передаем необходимые данные контроллеру
//...
// Показываем его выезжающим снизу
[self presentViewController:[authVC rk_vcToNavController] animated:YES completion:nil];

In order to close it later, call the method on the shown controller!
[self dismissViewControllerAnimated:YES completion:nil];

P
Petr2008, 2015-04-09
@Petr2008

+5 kopecks. If you work alone - do as you like, if in a team - through singleton, so as not to understand set and get.

I
iMike, 2015-04-05
@iFamily

Correctly and through segue and without it. And there can be no warning that you are acting somehow wrong. Attach a screenshot or at least the text of the warning. Surely this warning will talk about something other than navigation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question