I’m trying to use a global array in the appdelegate as a quick fix for a demo I’m building. The relevant code for this
.h file has the declaration
{
NSMutableArray *trnEntered;
}@property (nonatomic, retain) NSMutableArray *trnEntered
.m file has the following code –
trnEntered = [[NSMutableArray alloc] init];
NSLog(@"%@",[trnEntered count]); // prints null.
[trnEntered addObject:@"1"];
NSLog(@"%@",[trnEntered count]); // exec bad access.
Not sure where I’m going wrong here. Looks fairly straight forward.
Thanks for the help in advance,
Teja.
There seems to be a problem with your code:
Both calls to NSLog are trying to print an
NSUIntegeras an Objective-C object. This is going to cause a problem. You should useNSLog(@"%d", [trnEntered count]);I would suggest that you read more on format specifiers, there is a lot of useful information.
As a little more information: the second
NSlogis trying to print thedescriptionof the NSObject that the code claims is located at memory location 0x00000001.