iphone - NSDictionary losing its contents (exc bad access) -
So I have a uiviewcontroller, it has a property of NSMutableArray, which maintains a non-basic, synthesized property.
DeodeLoad in view I put it in with the following, and also add a button in 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": boole] KColorKey, zero]; NSLog ([NSString stringWithFormat: @ "LOOL% d", [test count]]);
The first log, when running through the debugger is running fine. However, I have tied the following code in the button:
- (zero) search: (id) from sender {nsstring string string with format: @ "lol% d", [test Count] ]);
When this code crashes with the bad bad access to the log line nothing the view is happening with the NSDictionary between the load and the button press, so why not Happening? And more importantly, how do I fix it?
Edit I thought maybe it was my SearchField class talking, so I changed them with simple strings, The problem still occurs.
You are reaching the member variable directly - you need to go through the accelerator - that is: Make sure that your object retains the dictionary.
self.test = [NSDictionary dictionaryWithObje ...
Comments
Post a Comment