Where to initialize a NSMutableArray?
having an issue using a NSMutableArray;
In my implementation file applicationDidFinishLaunching method I have
_imgArray = [NSMutableArray array];
and _imgArray is defined in my .h file as
NSMutableArray *_imgArray;
After populating it, it traces out correctly.
The problem is, in another method in my implementation file, I can't seem to acces the _img开发者_运维知识库Array array. It traces out to
_imgArray= ar.lproj
What gives?
I'm surprised you're not crashing. You aren't retaining the array when you assign it to _imgArray, so by the second event loop, it's pointing to unallocated memory.
Don't mess with your ivars directly. Use accessors (@property). And study the Memory Management Programming Guide.
精彩评论