2. Barriers to Entry
• Objective C
• I can’t see my code for all the square brackets
• Development Tools
• I survived XCode and lived to tell the tale
• Real Software?
• Only people that don’t know how to program write iPhone Apps?
3. Learning the Hard Way
• Memory Model
• Get your memory management right the first time
• Frameworks
• Don’t fight the framework
• View Lifecycles
9. Using your Class
ExtraClass *extraClass = [ExtraClass defaultExtraClass];
SomeClass *someClass =
[[SomeClass alloc] initWithExtraClass:extraClass];
// do some stuff with your class
ExtraClass *fromAccessor = [someClass extraClass];
[someClass release];
someClass = nil;
10. Looking Forward
• Barriers to entry are more like hurdles
• Objective C is not as bad as I thought
• XCode 4 to save the day?
• Don’t give up on testing
- Barriers to entry:\nObjective C: not a pretty language, message passing, small talk\n- semi-dynamic (responds to, contexts, monkey patching)\n- header files & properties\nDevelopment Tools: developers are second class citizens, testing difficult, TDD/Agile, refactoring\n- get to know the tools\nHobby only: reflected in developer tools, not going for corporate market, no pressure to learn it\n
- Objective C 2 autorelease pool (now available on iPhone)\n- memory leaks are much easier to avoid than they are to track down\n- follow conventions for autorelease/retain\n- frameworks: UIKit, CoreGraphics, CoreAnimation, CoreData, Three20/Facebook\n- view lifecycles: - when views are created and destroyed\n- low memory conditions\n- make sure your delegates are still there\n
IB - drag and drop\n - probably ok if you’re using the framework exactly as intended\nhand-roller controllers\n- safer option if you want control\n
OCUnit, GTM Test (Google Toolbox for Mac)\nGHUnit - can be used with both testing frameworks\n- run unit tests on the device\nOCMock - instance methods only, swizzle for static methods\nInstruments - with XCode 3.2.3 or so, iPad version (on device in iPhone 4)\nUIAutomation - Javascript hooks, device or phone, Jasmine (RSpec/ScrewUnit-like)\nManual Tests - document reproducible steps (Gherkin-like syntax)\n
Really for any mobile platform\nPersistence - application lifecycle (multitasking without multitasking)\n- good for users, bad for developers\n- needs to keep track of your state all the time\nPerformance - multiple devices to test on\n- must do device testing (simulator has a lot more resources)\nResolutions - \nDropouts - anyc requests, what to do?\n
forward class definition\ntrailing underscore to not clash with frameworks\n+ for class level methods, - for instance level\n\nnonatomic guarantees the whole value is received or set, not thread safety\nOther Property Types:\ncopy - when mutable subclasses\nassign - for primitive types, and delegates\n
import - like include with a #ifdef guard for multiple inclusion\nprivate parts in “anonymous” categories, no extra attributes\n(doesn’t mean people can’t use the private methods)\nanonymous vs named categories\n; on methods so the same as header, for copy and paste (not here)\nsuper - needs to be called (returns self, does not set it, so assign)\nuse properties with messaging not . syntax so not confused with C structs\n
Call class method on extra class, convention means this is autoreleased\n- anything that wants to keep it needs to call retain, or it will get cleaned up\nrelease any objects that are\nnil - can pass it messages, it just does nothing (clean and readable not equivalent)\n
Objective C is not too bad\n- long lines, lots of brackets, after a while see bbrh\n- code actually reads quite nicely\nXCode 4 looks a lot better\nTesting - don’t revert back to old habits\n- new platform, don’t know use in advance, test after?\n