Objective-C on Palmos?

Objective-C on Palmos?

Post by Michael As » Tue, 22 Jul 2003 23:05:26

> >There are three very simple rules:

> >   - +alloc new memory, -retain memory you plan to keep hold of for a while
> >   - -release what you +alloc, -copy, or -retain when you're done with it
> >   - -autorelease temporary values (if an exception occur in the local
> >     scope of the temporary value, then the value will for certain be
> >     -release'd by the current autorelease pool, but if it were not
> >     -autorelease'd and you had a -release message at the end of the scope,
> >     and an exception occur, memory would leak)

> Fourth rule - if you use Cocoa GUI objects from outside the main thread,
> you have to create your own autorelease pool, eg:

>    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

>    [pool release];

It has nothing to do with Cocoa GUI objects, but rather things that use
-autorelease. This can happen with just Foundation objects.