Genome Studio A Collaborative Multiuser Music Sequencer

17Jun/091

Day 3 learning objective c

Getting more comfortable with the language. Working on coding some custom controls, figuring out CoreGraphics, etc. Also installed the new OS 3.0 stuff.

Questions:

  • Why do I see this in some example source:  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ....  some code .....  [pool release];
    Why is this necessary?
  • Why is it that messing up a method call on an Objective C object results in a crash that provides no useful debugging info? it seems like most crashes on the iphone don't give you a proper line number.. Am I missing some project setting?

Filed under: IPhone Leave a comment
Comments (1) Trackbacks (0)
  1. The autorelease pool serves as a flushing mechanism, mainly for objects fetched through foundation calls (example: [NSMutableArray arrayWithCapacity:0]) where you yourself are not allocating these objects. When theyre returned to you, they are set to autorelease (this is the Apple standard and anyone who makes such methods should definitely follow it).
    So basically, anything created and set to autorelease within a pool will be released when the pool is released. So basically its just a memory optomization technique.

    Exception handling on ObjC is not nearly as useful as in other languages. The stack traces only point you to memory addresses and nothing useful (at least…as far as I can tell). Look up how to enable NSZombie in your code. This will at least give you more insight into those ‘BAD_ACCESS’ errors.


Leave a comment


No trackbacks yet.