Re: What, exactly constitutes a mutable action on an instance?
Re: What, exactly constitutes a mutable action on an instance?
- Subject: Re: What, exactly constitutes a mutable action on an instance?
- From: Diederik Meijer | Ten Horses <email@hidden>
- Date: Wed, 29 May 2013 07:37:47 +0100
May I add two questions to this enlightening thread?
1. With ARC, do we still have to worry about string1 leaking in the following scenario?
@property (nonatomic, copy) NSString *string1;
…..
self.string1 = @"Hello";
string1 = @"Hello hello";
string1 = @"Hello hello hello";
2. How do the strong, copy and weak keywords in the property declaration affect this?
Thanks!
Diederik
Op May 28, 2013, om 10:16 PM heeft Jens Alfke <email@hidden> het volgende geschreven:
>
> On May 28, 2013, at 6:39 AM, Alex Zavatone <email@hidden> wrote:
>
>> NSString *myString;
>
> You’ve declared myString as a _mutable_ pointer to an _immutable_ object. If you had declared it as
>
> NSString* const myString = @“Hi";
>
> then the variable itself would be immutable, and the compiler would give you an error if you tried to reassign it. (You often see this style used when declaring a string constant in a header file, since it’s supposed to stay constant and no one should reassign it.)
>
> Working with C++ will beat this concept into your head (for better or worse).
>
> —Jens
> _______________________________________________
>
> 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
_______________________________________________
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