• 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: NSImage initialization question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage initialization question


  • Subject: Re: NSImage initialization question
  • From: Julien Jalon <email@hidden>
  • Date: Mon, 5 Nov 2001 23:20:00 +0100

Le lundi 5 novembre 2001, ` 09:48 PM, Dan Huntsinger a icrit :

- initObject
{
if (self = [super init])
{
/* class-specific initialization goes here */
NSString *title;

title = [[NSBundle mainBundle] pathForImageResource:@"aSrcImage"];
theImage = [[NSImage alloc] initWithContentsOfFile:title];


// [title release]; // causes crash "EXC_BAD_ACCESS"
// [title autorelease]; // causes crash "EXC_BAD_ACCESS"
}

return self;
}

[...]
I understand that when I release title, I get the error because later on, it
is trying to access the "title" string which no longer exists. I thought
that "autorelease" might solve it but that doesn't work either. Can anyone
explain to me (better than apple's docs do) how images are initialized and
used, and why I need to keep the "title" string around for longer than this
method.


title and theImage are autoreleased. See:
<http://www.stepwise.com/Articles/Technical/MemoryManagement.html>

--Julien


References: 
 >NSImage initialization question (From: Dan Huntsinger <email@hidden>)

  • Prev by Date: Re: AppleDouble format
  • Next by Date: Re: [Q] Keyboard repeats stop when I hit another key. How do I get them back?
  • Previous by thread: NSImage initialization question
  • Next by thread: Re: NSImage initialization question
  • Index(es):
    • Date
    • Thread