Reputation: 3230
I create a property countryNameInitials
as NSMutableArray in AppDelegate.m interface and synthesize it. The purpose is to store global data to display in table view. In the table view controller:
#import "AppDelegate.h"
...
@implementation
#define AppDelegate [[UIApplication sharedApplication] delegate]
...
The problem is that I cannot use AppDelegate.countryNameInitials
to access the data. Any idea?
Upvotes: 1
Views: 202
Reputation: 3230
The problem of accessing countryNameInitials
is due to I declared the property in AppDelegate.m. After I move it to AppDelegate.h, errors are gone.
Side notes:
1. AppDelegate
as the identifier name works for me. Naming conflicts suggested by @Vakio is not relevant.
Upvotes: 0
Reputation: 69027
The fact is that
[[UIApplication sharedApplication] delegate]
will give you a generic UIApplcationDelegate
; while you need your MyOwnAppDelegate
(don't know how you called it) type to be able to use your countryNameInitials
property. So, try with:
#define AppDelegate ((MyOwnAppDelegate*)[[UIApplication sharedApplication] delegate])
then
AppDelegate.countryNameInitials
should work.
(I would not use the same name for the class and the macro, though).
Upvotes: 3