Search code examples
objective-csyntaxmutable

Is mutableCopy an Object's State or Behaviour?


I personally adhere to the 'using dot notation in Objective-C with state, and messages with behaviour' principle. I don't want a conversation about this, but more whether the method, mutableCopy, is state, or behaviour?

Perhaps I should do more research on the difference between state and behaviour, but from what I know, I am not sure in this case.


Solution

  • Behavior. A copy of an object is not something related to "some specific property of the object". It's creating a new object from an original one. So please do not write

    NSMutableArray *mutArr = array.mutableCopy;