Encountering a strange issue debugging some code on Xcode 6.1 where the value of an NSArray I am debugging has objects yet the debugger shows nothing when inspecting individual elements. Here's what I am seeing in the debugger...
The kPatternDifficulties array is being filled used the following line of code...
NSArray *kPatternDifficulties = [self.definition objectForKey:@"pattern-difficulties"];
Usually when I see something like this I find a great cursory check is whether optimizations are turned on for the particular scheme/configuration being run. In this case turning off optimizations did nothing. As a next step I had figured this might be a memory issue perhaps the contents of self.definition being autoreleased ahead of time so I tried switching the above line to a copy instead of an assignemnt...
NSArray *kPatternDifficulties = [NSArray arrayWithArray:[self.definition objectForKey:@"pattern-difficulties"]];
And that works. I can correctly see all the elements of the NSArray so I have a solution which is great. I do have some questions such as...
- This is causing a crash on iOS8 devices only. Previous iOS versions seem to fail silently would there be something notable around memory management changed in iOS8 that might be a reason for this?
- What would be the general convention/standard around a case like this? Is it acceptable to assign to a variable or would a copy be the more correct approach? I'm reading an NSArray out of self.definition which is retained by the object itself so I don't think it should be released in anyway till the object is released and yet there does seem to an issue accessing this memory as is.