Re: NSMutableDictionary autorelease chrashes application
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