• 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: Several questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Several questions


  • Subject: Re: Several questions
  • From: "David P. Henderson" <email@hidden>
  • Date: Tue, 3 Jul 2001 00:38:02 -0400

On Monday, July 2, 2001, at 09:26 , Hisaoki Nishida wrote:

> 1. retain and copy: what determines which I should use?
>
Use retain when you don't need to create a distinct object, and copy
when you do. Use retain or copy on objects which need to persist beyond
the scope of the current event loop.

> 2. What's the difference between - and + (in method declarations)?
>
- signifies an instance method whereas + signifies a class method.

> 3. What's the difference between @class and import? I can't distinguish
> their use.
>
#import is an improved way of doing #include. @class is a forward
declaration, you are letting the compiler know that the class(es) named
in the @class declaration are not defined in the file but that they will
be defined at some point.

> 4. When you autorelease something, it ceases to exist when the "event
> loop" is finished. What does this mean?
>
Cocoa uses reference counting for memory management of objects; an
object's memory is released when its retain count reaches zero (0).
Autoreleasing defers returning an object's memory by placing the object
in the auto release pool which allows another object time to retain the
object before it is destroyed. [object release] decrements the retain
count immediately and may result in the object's deallocation whereas
[object autorelease] defers decrementing the retain count until the auto
release pool is destroyed at which time if the object's retain count is
0, it is deallocated.

Dave
--
Chaos Assembly Werks
"Imagination is more important than knowledge."
- Albert Einstein


References: 
 >Several questions (From: Hisaoki Nishida <email@hidden>)

  • Prev by Date: Re: Getting the user's name from cocoa
  • Next by Date: How do I get services?
  • Previous by thread: Re: Several questions
  • Next by thread: Re: Several questions
  • Index(es):
    • Date
    • Thread