Stack Overflow is a remarkable site. Billed as a “collaboratively edited question and answer site for programmers” it manages, through a clever hybrid of wiki-style collaborative writing and a reputation system, to be actually helpful.
Stack Overflow has a treasure trove of iPhone, Objective-C and Xcode related material. It’s a great place to pick up good software engineering practices, programming and dev-environment tips, and to avoid the common (and un-common) pitfalls that lie waiting for us.
To highlight some of the best of Stack Overflow as it relates to iPhone development I’m starting a new periodic “Best of Stack Overflow For iPhone Devs” feature. Enjoy:
What are best practices that you use when writing Objective-C and Cocoa? — A case for putting dealloc at the top of a .m class, performance gains of opaque (vs. transparent) cells, performance gains for non-atomic properties, memory semantics for IBOutlets, and more!
Tips for a successful AppStore submission? — An always popular topic here, the Stack Overflow thread includes speculation about Apple checking-or-not-checking for memory leaks, tips to ease the complexity around code-signing, bundle identifiers and version numbers, and more.
Formatting a (large) number “12345” to “12,345” — A great real answer (use NSNumberFormatter — I had’t run across this before) and one laughable one to boot.
What are those little Xcode tips & tricks you wish you knew about 2 years ago? — Lots of goodies to make you proficient, and efficient, in Xcode. Examples: using ctrl-/ to jump to the next argument in Code Sense completion; using the pre-processor on your Info.plist file.
Checking For Internet Connectivity in Objective C — Answer: Apple’s Reachability sample code demonstrates how “to use the System Configuration framework to determine the network state of an iPhone or iPod touch. In particular, it demonstrates how to know when IP traffic might be routed through a carrier data network interface (such as EDGE).”
Programmatically get own phone number in iPhone OS — ‘Nuff said.
Cocoa Bad Habits — Passing nil to arguments that call for NSError**, lazy use of accessors within a class, exceptions as flow control, and more. When used as a what-not-to-do list it’s a surprisingly good way to notch up the quality of your code.
Can I embed a custom font in an iPhone application? — Very cool: an answer pointing to a github hosted project module that extends UILabel to support including your own .ttf fonts.
Understanding reference counting with Cocoa / Objective C — When I’m trying to wrap my head around some hard-to-grok concept, I find it helpful to have a bunch of people try to explain it to me independently. The subtle variations in their approaches help me glue the concepts down. This question features 14 different answers to piece together your own understanding.
Why do Programmers Love/Hate Objective-C? — How did this not turn into a flame war?