Reputation: 909
I am attempting to create a global variable as outlined in the tutorial here. Howeer, when I attempt to assign my AppDelegate with the following code, I'm getting an error relating to no declared @interface for 'delegate'
AppDelegate = [(RoadSafetyAppAppDelegate *)[UIApplication sharedApplication] delegate];
Basically, i have a string declared in my app delegate which i need to use as a global variable, but i can't access it because of this error.
Can anyone see what is going wrong?
Upvotes: 0
Views: 1108
Reputation: 318794
The cast is in the wrong place. You want:
AppDelegate = (RoadSafetyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
You want to cast the result of the call to delegate
, not the call to sharedApplication
.
BTW - it is standard practice to name variables and methods starting with lowercase letters. Only start class names with uppercase letters.
Upvotes: 2