PDA

View Full Version : two identical lines.. one causes an uncatchable error the other not




Chirone
Sep 3, 2009, 05:45 PM
typo... woops... can this thread be deleted?

NSDictionary *testDic = [NSDictionary dictionaryWithObjectsAndKeys:
@"value1", @"key1", "@value2", @"key2", nil];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
@"value1", @"key1", @"value2", @"key2", nil];

what's the difference between these two lines?
The difference is is that the first line (written by me) causes an uncatchable error (i put it in a try catch and it still crashed)
and the second line is from the documentation about NSDictionary

I see two completely identical lines (apart from the variable name)

I took out the first line and it worked fine, but as soon as it was put back in it crashed.

what could cause this?



Cinder6
Sep 3, 2009, 05:51 PM
Is it the EXEC_BAD_ACCESS error? If so, you're not properly retaining the dictionary--dictionaryWithObjectsAndKeys: gives an autoreleased object. Are you trying to access it outside of the scope where you create it?

Chirone
Sep 3, 2009, 05:54 PM
yeah it was, could only see it with breakpoints

the typo is one the first line... "@key2" should be @"key2"
:rolleyes:

petron
Sep 4, 2009, 03:00 AM
Typo yepp but "@value2" should be @"value2"