0

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 _imgArray array. It traces out to

_imgArray=  ar.lproj

What gives?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep needed to retain it. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.