Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary autorelease chrashes application



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.