Reputation: 1909
I have a NSString declared in my AppDelegate. I am trying to read/write that string from my View class but it's giving me error about getter/setter method not found.
Here's how i am accessing it:
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.myString = @"test";
Upvotes: 0
Views: 2995
Reputation: 25011
How do you have the myString
property defined?
In order to access it as you say, you need at 3 things:
In the interface, have a variable defined and a @property
, and in the implementation a @synthetize
.
Something like:
// MyAppDelegate.h
@interface MyAppDelegate
NSString *myString;
@end
@property NSString *myString;
// MyAppDelegate.m
@implementation MyAppDelegate
@synthetize myString;
@end
Upvotes: 4