• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What, exactly constitutes a mutable action on an instance?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:19:45 -0400

Alex,

Forget what I said about memory management. It is wrong.

Your confusion probably stems from the fact that the pointer named myString is allowed to point to any number of string during the execution of your program. It is the objects that are immutable, not the pointers to them.

Tom Wetmore

On May 28, 2013, at 12:11 PM, Thomas Wetmore <email@hidden> wrote:

> 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


_______________________________________________

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

References: 
 >What, exactly constitutes a mutable action on an instance? (From: Alex Zavatone <email@hidden>)
 >Re: What, exactly constitutes a mutable action on an instance? (From: Thomas Wetmore <email@hidden>)

  • Prev by Date: Re: What, exactly constitutes a mutable action on an instance?
  • Next by Date: Re: rate limiting calls
  • Previous by thread: Re: What, exactly constitutes a mutable action on an instance?
  • Next by thread: Re: What, exactly constitutes a mutable action on an instance?
  • Index(es):
    • Date
    • Thread