iosobjective-csparrow-framework

Pointer returning as nil in obj-c


I'm initialising a pointer to a SPSprite object (sparrow framework) like this...

SPSprite *mySprite = [[SPSprite alloc] init];

I'm then saving that pointer in a NSMutableDictionary like this...

[objectDynamic setObject:mySprite forKey:@"objectSprite"];

But when I try to access that object at a later point in the code with this...

SPSprite *mySprite = [objectDynamic objectForKey:@"objectSprite"];

mySprite = 0x00000000 when I look at it in the debugger, when I do a print though on objectDynamic I get this..

objectSprite = "<SPSprite: 0x162e7d40>";

Which is the same as it was when it as alloc'd/initalised, so I'm a tad confused as to what's going on.

I'm using ARC.


Solution

  • Check your key is the same (in fact, I would #define it so you avoid typos).