0

First i was wondering if this is a good idea, essentially i have user class and throughout the application i would have a current user and various views would want to access this users data. would it make sense to store this user in the navigation controller so that each class can access it without having to pass it through the prepareforsegue on every view?

Second if this is ok to do, how do i access a variable in the navigation controller? i have it setup so it has one called _myUser just like i would in the other views but how do i call/set that from a view?

Kyle Fuller
  • 117
  • 2
  • 13

1 Answers1

0

I would recommend saving data to either your application delegate or if it starts to get messy creating a singleton. The application delegate is a better practice and can be shared throughout your app easily. You can access it easily with something like this:

YourAppDelegate * del = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"%@", del.yourPropertyToShare);
rooster117
  • 5,502
  • 1
  • 21
  • 19