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 protected])
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/archive%40mail-archive.com
This email sent to [email protected]