• 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
Memory Management question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory Management question


  • Subject: Memory Management question
  • From: Scott Wilson <email@hidden>
  • Date: Thu, 25 Dec 2008 11:30:55 -0800

I have an odd case. I've got a NSTextView delegate method which looks like this:

- (BOOL) textView: (NSTextView *) textView
clickedOnLink: (id) link
atIndex: (unsigned) charIndex
{
...

NSURL *desiredURL;

// is it a NSURL link or a NSString link?
if ([link isKindOfClass: [NSString class]])
{
...
desiredURL = [NSURL URLWithString: [link stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding] relativeToURL: lastOpened];


} else if ([link isKindOfClass: [NSURL class]]) // this is the case which causes the problem!!
{
desiredURL = link; // it's a regular file:// URL

} else return NO;


NSLog(@"url %@", [desiredURL path]); // get EXC_BAD_ACCESS if link was an NSURL

...
}


If I change the code above to desiredURL = [link retain] everything is fine. I've used very similar code with no problems in a different context.

Is it possible that link is being autoreleased before my method has returned?

Thanks

_______________________________________________

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: Memory Management question
      • From: j o a r <email@hidden>
    • Re: Memory Management question
      • From: Robert Marini <email@hidden>
  • Prev by Date: Re: Modal Session not stopping main thread.
  • Next by Date: Re: Merry Christmas
  • Previous by thread: [Moderator] Re: Merry Christmas
  • Next by thread: Re: Memory Management question
  • Index(es):
    • Date
    • Thread