This is a noob question. If I have a ViewController and inside that class I have an object called UserInfo and other ViewController, lets just call it X,Y,Z, etc..etc.
W开发者_开发技巧hat do I need to do so that those X,Y,Z can use the information of UserInfo?
Well I can have another info called UserInfo inside X,Y,Z and pass UserInfo inside, but I don't think this is good OOP technique. I think inheritance is needed here... but I don't think that it is right too, as the only commonality they have is only the UserInfo
View controllers are just objects, you have to remember that.
If you're in your first view controller and it has a property NSString *aString
to pass it to the next view controller you just make the second view controller's NSString *aString
property equal to the first one.
Basically do this:
MyNextViewController *viewControllerTwo = [[MyNextViewController alloc] initWithNibName:nil bundle:nil];
[viewControllerTwo setAString:self.aString];
if you subclass all you inherit are the properties, and not their values.
精彩评论