• 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: NSMutableDictionary autorelease chrashes application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary autorelease chrashes application


  • Subject: Re: NSMutableDictionary autorelease chrashes application
  • From: Andy Lee <email@hidden>
  • Date: Sat, 19 Jul 2008 14:31:49 -0400

On Jul 19, 2008, at 11:11 AM, Uli Kusterer wrote:
On 19.07.2008, at 05:52, Andy Lee wrote:
I'm confused by this statement. Take that simple C++ String class again. If you have:

  String a = "aaa";
  String b = a;
  String c = a;

...don't a, b, and c all own the underlying char buffer? (And yes, a char buffer isn't an object, but that's what the article you linked to is referring to when it mentions ownership.)


Well, I presume you mean the "underlying buffer" is the copy that 'a' creates from the "aaa" string in its constructor? Because, as you're aware, but a beginner following this thread might not,

Yes -- thanks for pointing out this possible confusion.

For those who don't know, in C++ you can create a String class such that

    String a = "aaa";

creates an object with a private internal buffer that is a *copy* of the C string "aaa". And

    String b = a;

causes b to share that same internal buffer but increment a reference count on it. In other words, don't be confused because the above looks similar to

    char *x = "aaa";
    char *y = x;
    char *z = x;

They are totally different.

If you want a fun description of problems like these, look up James Dempsey's "Designated Initializer" song on YouTube.

How I wish I'd been there.

--Andy


_______________________________________________

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: 
 >NSMutableDictionary autorelease chrashes application (From: Matthias Arndt <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Andy Lee <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: mmalc crawford <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Andy Lee <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: j o a r <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Andy Lee <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: "Michael Ash" <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Andy Lee <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: "Michael Ash" <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Andy Lee <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: "Michael Ash" <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Andy Lee <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Autosaving in an NSPersistentDocument
  • Next by Date: Re: CoreData Property access compiles, but fails at runtime
  • Previous by thread: Re: NSMutableDictionary autorelease chrashes application
  • Next by thread: Re: NSMutableDictionary autorelease chrashes application
  • Index(es):
    • Date
    • Thread