I think I am beginning to understand this. > What gives you the impression that NSObject (and thus all of its subclasses) > conform to NSCopying?
I think I was wrong... I will read the documentation about this. > A property should be copy when you are interested in the *value* of the > thing being set. > > A property should be retain when you are interested in maintaining a > relationship to the thing being set. > How about assign ? > Consider a Person object. > > Person *person1 = [[Person alloc] init]; > Person *person2 = [[Person alloc] init]; > > NSMutableString *string = [NSMutableString string]; > > [string setString: @"Jim"]; > person1.name = string; > > [string setString: @"Ignacio"]; > person2.name = string; > > If name were specified as > > @property(retain) NSString *name; > > then both people would now be named "Ignacio" (person1 having been changed > by side effect), which is not what we want in this situation. > > However, if we had a parent property, we are interested in the relationship > to the parent (i.e. we don't want a separate copy), so retain, not copy, > would be more appropriate here. > What would be the result with assign? Regarding former responses... "aObject.property" is like using getter and setter methods (depending on the situation) and just "property" is going directly to the property ... Did I get it right? if so, why using setter methods when I can use it as it? _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
