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.

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