• 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: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

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

  • Prev by Date: Re: rate limiting calls
  • Next by Date: Re: What, exactly constitutes a mutable action on an instance?
  • 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