How to access a property value of AppDelegate class from someView Controller without creating reference of the delegate in view controller?
Your app delegate object manages your app's shared behaviors. The app delegate is effectively the root object of your app, and it works in conjunction with UIApplication to manage some interactions with the system.
I'm not quite sure what you mean - there are multiple ways to get information from your application delegate into a view controller, and the phrase "without creating reference of the delegate" is unclear. Your options basically are:
id propertyValue = [(MyAppDelegate *)[[UIApplication sharedApplication] delegate] myProperty];
@property
declared and @synthesize
d for use, then you would have the app delegate just set the property on the view controller instance.Neither of these options require that you retain a copy of your app's delegate as a @property
, but the first does reference the delegate once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With