-1

I have an UIViewController in wich I imported a class:

#import "differenza.h"

and then I created an instance of that class when a button is pressed:

- (IBAction)ok:(id)sender {

    differenza *classeDifferenza;
    classeDifferenza = [[differenza alloc] init];

    [classeDifferenza metodo];    

}

As you can see, I also called a method.... now I don't have enough space in that UIViewController for the results of that method, so I need a new ViewController to show all the results... but I don't know how to recall results from that new ViewController, as I can not use the

classeDifferenza.variabile 

way ....

This is something I did not really get already. In the past I used (thanks to your help: Setting up class instances in a multi view app (Objective C)) a "common class" where to store all data and all methods... but I don't think It's always the proper way... I feel like I am abusing that solution... or It's the right way to do what I described?

Thanks!

Community
  • 1
  • 1
Funesto
  • 67
  • 1
  • 9
  • I would make the `differenza` object an instance variable and use a delegate to call back from the new view controller to retrieve the results of calling `metodo`. – trojanfoe Jul 22 '14 at 10:53
  • This is exactly the same as the question you refer to in the bottom, put that `differenza` object as a property onto a singleton (what you call 'common class') and then you can access it from anywhere inside your app. An other approach here is to store it as a property on the actual class and implement prepareForSegue: and pass it to the `destinationViewController` there. Also, if you are just beginning iOS development I recommend you watch Stanford's latest iOS development course on iTunes U it really helps to get started! – Rickye Jul 22 '14 at 10:56

1 Answers1

0

You can pass data with prepareForSegue check this topic How to pass prepareForSegue: an object

You can send variable results like that

Community
  • 1
  • 1
Gökhan Çokkeçeci
  • 1,388
  • 3
  • 16
  • 37