Couldn't I just pass an copied string to an Core Data property?
        Posted  
        
            by dontWatchMyProfile
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by dontWatchMyProfile
        
        
        
        Published on 2010-06-11T13:00:33Z
        Indexed on 
            2010/06/11
            13:02 UTC
        
        
        Read the original article
        Hit count: 249
        
The docs say:
The default implementation does not copy attribute values. If the attribute value may be mutable and implements the NSCopying protocol (as is the case with NSString, for example), you can copy the value in a custom accessor to help preserve encapsulation (for example, in the case where an instance of NSMutableString is passed as a value).
So instead of getting into trouble and inconvenience with overwriting accessors in my NSManagedObject subclass, couldn't I simply do something like this?
myManagedObject.firstName = [[firstNameMutableStr copy] autorelease];
This would have the exact same effect, or not? The dynamic implementation would retain that anyways ... so.... why not the easy way?
© Stack Overflow or respective owner