views:

71

answers:

1

I have two NSMutableArrays:

NSMutableArray* currentMessages
NSMutableArray* items

I am trying to copy the contents of items into currentMessages as such:

[self.currentMessages addObjectsFromArray:self.items];

When I am debugging self.items contains 30 objects. After this operation self.currentMessages contains 0 objects.

Why is the copy not working?

+2  A: 

Dollars to doughnuts currentMessages is nil. A message to nil just returns nil or 0, so the message to add objects would be a no-op and then asking nil for its count will return 0. You need to allocate an NSMutableArray for that property.

Chuck