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

Autopool question


  • Subject: Autopool question
  • From: Lars Hoss <email@hidden>
  • Date: Tue, 7 Aug 2001 16:26:19 +0200

Hi!

I have a little question about autorelease pools and how they
free objects.
Let's assume I have the following method in the class Foo:

-(MyObject *)object
{
// create a MyObject instance somehow ...
// ref counter on myObject is now 1
MyObject *myObject = ...
[myObject autorelease];
return myObject;
}

Then I have a method in the class Foe:

-(void)doSomethingWithObject
{
Foo *fooInstance = [[Foo alloc] init];
myObject = [fooInstance object]; // myObject is a class variable
[myObject retain]; // ref counter now is 2
[fooInstance release];
}

The class Foe needs the instance foo for a longer time.
Since I put myObject into the autorelease pool wouldn't
it be freed after two event cycles?

Thanks for your help in advance.

Yours,
Lars

--
mailto:email@hidden
icq: 19903263


  • Follow-Ups:
    • Re: Autopool question
      • From: "Dennis C. De Mars" <email@hidden>
  • Prev by Date: AW: Autorelease pool - was Beginners question regarding NSFileHandle
  • Next by Date: Inspector Panel
  • Previous by thread: AW: Autorelease pool - was Beginners question regarding NSFileHandle
  • Next by thread: Re: Autopool question
  • Index(es):
    • Date
    • Thread