Search code examples
objective-cnsmutablearraydeep-copy

Add object to NSMutable Array, deep copy


I declare a property in my class: NSMutableArray *data;

classmethod{
  [self.data addObject: message];
}

It's adding the reference of message to the array, when the method ends, data's content would set to nil, is there a way I can do deep copy then add message to the array without losing it when the method ends.


Solution

  • The properties of message should be set "Strong"!