Re: literal strings - who do they belong to?
Re: literal strings - who do they belong to?
- Subject: Re: literal strings - who do they belong to?
- From: Charles Srstka <email@hidden>
- Date: Mon, 13 Jul 2009 03:26:10 -0500
On Jul 13, 2009, at 1:22 AM, Jeff Laing wrote:
{
Object *o = [Object new];
NSString *s = o.somevalue; // gets o's instance variable (without
retain)
[o release]; // o's instance variable is released
NSLog(@"Crash: %@",s) // accesses dead string
}
Wouldn't this generally be something that common sense would tell you
not to do, anyway? Working with an object's internal state after it's
been released isn't a particularly safe thing to do, and can't always
be made to behave correctly anyway. For example, you'd never do a
thing like this:
{
NSData *data = [[NSData alloc] initWithBytes:foo length:bar];
const char *bytes = [data bytes];
[data release];
CrashByDoingSomethingWithBytes(bytes);
}
Why should this sort of thing be expected to work, just because the
property in question happens to be an object?
Charles
_______________________________________________
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