• 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: literal strings - who do they belong to?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • RE: literal strings - who do they belong to?
      • From: Jeff Laing <email@hidden>
References: 
 >literal strings - who do they belong to? (From: William Squires <email@hidden>)
 >Re: literal strings - who do they belong to? (From: Bill Bumgarner <email@hidden>)
 >Re: literal strings - who do they belong to? (From: Peter N Lewis <email@hidden>)
 >Re: literal strings - who do they belong to? (From: Wade Tregaskis <email@hidden>)
 >RE: literal strings - who do they belong to? (From: Jeff Laing <email@hidden>)

  • Prev by Date: Re: [iPhone] Addressbook "group" problem
  • Next by Date: Re: literal strings - who do they belong to?
  • Previous by thread: Re: literal strings - who do they belong to?
  • Next by thread: RE: literal strings - who do they belong to?
  • Index(es):
    • Date
    • Thread