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: Jens Alfke <email@hidden>
- Date: Tue, 28 May 2013 14:16:17 -0700
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