alloc NSMutableArray and storing objects

Today’s interesting programming tidbit…

If assigning an array to another NSMutable Array such as this:

self.listData = [self userData];

You don’t need to alloc the listData array first, although i’m guessing it’s probably a good idea.

However if you want to do this:

“[selectedData addObject:name];”

You need to alloc it first:

“selectedData = [[NSMutableArray alloc] init];”

I believe i read that somewhere, wish I could have remembered it while i was pulling my hair out wondering why my NSMutableArray wasn’t storing values.

Retweet
This entry was posted in Apple, Programming, Technology. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>