Hi
So i have a uiviewcontroller. It has a property of an NSMutableArray with a nonatomic, retain property synthesized.
In the viewDidLoad I init it with the following, and also add a button to the nav bar.
test = [NSDictionary dictionaryWithObjectsAndKeys:
[[SearchField alloc] initWithName:@"Subject" :Text], kSubjectKey,
[[SearchField alloc] initWithName:@"Source publication" :Text], kSourceKey,
[[SearchField alloc] initWithName:@"Keyword" :Text], kKeywordKey,
[[SearchField alloc] initWithName:@"Author" :Text], kAuthorKey,
[[SearchField alloc] initWithName:@"Color" :Bool], kColorKey,
nil ];
NSLog([NSString stringWithFormat:@"lol %d", [test count]]);
The first log, when running through the debugger runs fine. However, I have tied the following code to the button:
-(void)search:(id)sender{
NSLog([NSString stringWithFormat:@"lol %d", [test count]]);
When this code executes the log line crashes with exc bad access. Nothing is happening to the NSDictionary between the viewDidLoad and the button press, so why is this happening? And more importantly, how do I fix it? :)
Cheers
Edit I thought maybe it was my SearchField class was doing things, so i replaced them with simple strings, the problem still occurs.