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: Thomas Wetmore <email@hidden>
- Date: Tue, 28 May 2013 12:11:07 -0400
Alex,
What your three lines of code do:
> NSString *myString;
Compiler allocates space for a pointer on the run time stack.
> myString = @"Hi";
Compiler creates an NSString object somewhere in the heap with the value @"Hi" and points the pointer to it.
> myString = @"Hi there";
Compiler creates another NSString object somewhere else in the heap with the value @"Hi there" and points the pointer to it. Depending on the type of memory management you are using the first string might leak since there is nothing pointing to it any more. If you are using ARC the compiler will insert a call to release to remove the first string.
There is nothing in your code that tries to mutate a string. All it does is create two different strings.
Tom Wetmore
_______________________________________________
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