Share
Embed
The Complexities of iOS Programming
Talk given at the ICAB, in the series of Betatech Talks (http://www.meetup.com/betatech-brussels)
Martin De Wulf
November 26, 2013
Transcript
20 slides
-
Who am I? • Background in research (PhD) but turned
into developer by the love of code. • 7 years doing research/teaching/programming at the university • 5 years doing web/mobile programming in startups and a web agency (Checkthis, Frontback, Mondial Telecom, “my media is rich”) • 3 years of iOS: -
I missed the gold rush of the app store. I
was too busy. -
iOS • Unix like OS: initially, Apple took Mac OSX
and stripped it down. • But they iterated a lot since then. • What is specific to development for iOS? -
It’s a mobile platform • Network is spotty/ Offline functionalities
are hard (iCloud anyone?) • Memory is limited (Over 70MB of RAM, your app will probably be killed by the system) • It is very stateful: no refresh button. -
How? Use concurrency! Do not do expensive CPU operations, disk
accesses or blocking network requests on the main thread. The catches: If you access the UI on a background thread: crashes and freezes Core data constraints Concurrency is hard -
Objective-C • It’s old, and it shows: the syntax is
crummy (but it’s getting better) [martin willDo:aTalk on:tuesday]; (http://fuckingblocksyntax.com) • But it is quite dynamic (selector, sizzling) • Object model is ok (less complex than C++). • Memory management is ok since ARC -
How are the APIs? • They date back to 1989:
solid, but not that modern. Lots of cruft. “More than one way to do it”. • Lots of C APIs: ABAdressBook, Core graphics (Objc-C method call model has performance impacts) -
Views layout • It’s a MVC model • Either UI
based with Interface Builder or code with absolute positions: No flow engine like in HTML • Text layout is hard: You would be surprised by how much code you need to write to get a label with a red link in a text. -
- (void)createSoldAttributedString:(NSNumber *)nbDownloads { NSString *soldNumberString = nbDownloads.stringValue; NSString *soldStringPattern
= NSLocalizedStringWithDefaultValue(@"accepted.cell.sold.label", nil, [NSBundle mainBundle], @"%@ sold", @"Accepted cell sold text"); NSString *soldString = [NSString stringWithFormat:soldStringPattern, soldNumberString]; self.soldAttributedString = [[NSMutableAttributedString alloc] initWithString:soldString]; [self.soldAttributedString addAttribute:NSFontAttributeName value:textFont range:NSMakeRange(0, [self.soldAttributedString length])]; [self.soldAttributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:135 / 255. green:134 / 255. blue:134 / 255. alpha:1.0] range:NSMakeRange(0, [self.soldAttributedString length])]; [self.soldAttributedString addAttribute:NSFontAttributeName value:textBoldFont range:[soldString rangeOfString:soldNumberString]]; [self.soldAttributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:69 / 255. green:72 / 255. blue:75 / 255. alpha: 1.0] range:[soldString rangeOfString:soldNumberString]]; } is approximatively the equivalent of <span style=“color: #ddd”>Sold: </span> <em style=“color: #aaa”>5</em> -
Backward compatibility? iOS 7 just forced all apps to change
their code base to adapt to the new design of the status bar Lots of bugs introduced with iOS7 too. -
Fighting the system • No long term background activity (battery)
unless you’re a VOIP or geo app. • You’re in a sandbox: no general file access, no real inter app communication (no common file system), no customization of the home screen. • Rules for IAPs : 30% to apple for virtual goods. -
App store review process • From 1 hour to 1
month (Average: 1 week) • No rolling back of buggy versions. • Expedited reviews • Things that were accepted could not be accepted again -
The doc • Hit or miss quality. No real errors,
but the language can be obscure. • Not enough official tutorials • Example code from Apple is of poor quality • Lots of the info is locked in WWDC videos. -
Other pains • Certificates: you need to sign your apps
to launch them on device, to upload them to the app store, to send push notifications, to use IAPs,… • Max 100 devices/account to test • XCode is a UI based programming env. Lots of source controle problems with generated XML files. • It’s closed source software. Some things are really hard to debug -
The good parts: • Animations • Text manipulations: unicode, emoji,
i18n (date, distances) தจ -> zhōng wén (http://nshipster.com/cfstringtransform/) • Photographic manipulation: included filters, face detection, very powerful and efficient (but C). • A new game SDK for 2d games: SpriteKit • Not much fragmentation. • Every user has entered his credit card -
The good parts (2) • The simulator is fast •
XCode is a good IDE (but opinionated) • Tooling: static analysis, profiling and debugger. New: continuous integration • The SDK is getting better by each release (QR Code, Blink, Speech Synthesis, iBeacon, Background fetch in iOS7) • Lots of work available lately. -
The community • Still rather small (<75 devs in Belgium?).
• Not many real indies, most devs are contractors. • Lots of old timers coming from the Mac, which is cool. • No testing culture • Podcast culture • Open source still a bit spotty (e.g. Twitter support as of last June) • Lots of paying tools. • Conferences tend to be expensive (WWDC :-( ).