Re: Objective 2.0 properties
Re: Objective 2.0 properties
- Subject: Re: Objective 2.0 properties
- From: "Ignacio Enriquez" <email@hidden>
- Date: Sat, 18 Oct 2008 02:59:49 +0900
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@hidden)
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:
This email sent to email@hidden