Tech06 May 2011 03:23 pm
WordPress noob attempts to help iPhone Dev Noobs.
Things I wish I’d known 2 years ago.
- Understand reference counting
-If you alloc, copy, new or retain an object, you must release it.
- Understand Zombies
-A deallocated object that your code thinks is still allocated.
- NSLog is your friend.
-When in doubt, print it out.
- Messaging a nil object no-ops silently.
-When you push a view controller onto your navigation controller and nothing happens, usually it’s because your navigation controller is nil.
- When things act weird, Clean your product and Reset the Simulator
- Connect your IBOutlets
-If it’s not hooked up, it won’t show up.
- If you’re fighting the API alot, you’re probably doing it wrong.
- Quadruple punctuation is a red flag; triple is a yellow flag.
[[[[[[anObject alloc] init] subViews] objectAtIndex:[Database funIndex] removeFromSuperview] retain] autorelease];
This is just asking for trouble; break it into multiple simpler statements. You can thank me later.
- Get out of the appDelegate as soon as you can.
-Create your main view controller and then go there. Don’t do UI, controller or database work in the app delegate unless you have to. Leave the appDelegate for app level stuff (foreground and background, external notifications, etc.)
- Treat Warnings as Errors (config your Project Build Settings, under GCC – Warnings).
- StackOverflow totally rocks.