two identical lines.. one causes an uncatchable error the other not

Discussion in 'Mac Programming' started by Chirone, Sep 3, 2009.

  1. Chirone macrumors 6502

    Joined:
    Mar 2, 2009
    Location:
    NZ
    #1
    typo... woops... can this thread be deleted?

    Code:
    	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?
     
  2. Cinder6 macrumors 6502

    Cinder6

    Joined:
    Jul 9, 2009
    #2
    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?
     
  3. Chirone thread starter macrumors 6502

    Joined:
    Mar 2, 2009
    Location:
    NZ
    #3
    yeah it was, could only see it with breakpoints

    the typo is one the first line... "@key2" should be @"key2"
    :rolleyes:
     
  4. petron macrumors member

    Joined:
    May 22, 2009
    Location:
    Malmo, Sweden

Share This Page