iPhone
coding
for web
developers

Matt Biddulph
www.hackdiary.com
From websites
to mobile apps
www.twitter.com
m.twitter.com
Twitterifc, Tweetie and Twitterfon
www.facebook.com
m.facebook.com
native iPhone app
Joe Hewitt on the
native Facebook app
“People must have assumed that
all I had to do was plug Facebook's
data into Apple's ready-to-use UI
components and hit th...
“I wish it had been that easy, but
unfortunately many of the
components I needed were missing
from the iPhone SDK, even th...
Phonegap
Building native internet apps
Internet app basics
Internet app basics


                 HTTP

                 JSON or XML

                 Regular Expressions

         ...
HTTP

NSURLRequest is fiddly.

I use GTMHTTPFetcher from
Google Toolbox for Mac.
http://code.google.com/p/google-toolbox-fo...
XML

Mac OS X has NSXMLDocument
for DOM parsing.


The iPhone only has NSXML for
SAX parsing. This is hard.
XML

     iPhone ships with libxml2. It is
     good, fast and has a nasty C API.

     Convenience wrapper functions
    ...
JSON

Objective C coders make liberal
use of mix-ins. Ruby coders fondly
call this ‘monkeypatching’.

#import quot;NSStrin...
Regular Expressions


Some people, when confronted
with a problem, think “I know, I'll
use regular expressions.”
Now they ...
Regular Expressions


Again, the iPhone’s string handling
has no regular expression builtins.


But it ships with the ICU ...
Regular Expressions

RegexKitLite extends NSString
with methods that bridge to ICU.


This gives you UTF-safe functions
wi...
Regular Expressions

As usual with Objective C, the
method names are rather verbose.

split: componentsSeparatedByRegex
gs...
Local Storage



SQLite is the iPhone’s default
database management library.


This is a good thing.
Local Storage




Yet again, it’s a C library that isn’t
integrated with Cocoa.
Local Storage


FMDB is an Objective C wrapper
modeled on Java’s JDBC. It’s
sensible.

FMDatabase* db = [FMDatabase databa...
A few words about
event-driven code
The user is in control
UI responsiveness and
rendering is a priority
Fallacies of
networked
computing
Fallacies of
networked
computing


               The network is reliable.

                  Latency is zero.

          ...
The world is asynchronous




                But threads are hard
Understand
delegation
thank you

Matt Biddulph
www.hackdiary.com



Flickr photo heroes:

http://www.flickr.com/photos/scobleizer/1215753803/
htt...
iPhone Coding For Web Developers
iPhone Coding For Web Developers
iPhone Coding For Web Developers
Upcoming SlideShare
Loading in...5
×

iPhone Coding For Web Developers

38,640

Published on

A perspective on iPhone development from a server-side developer with very little GUI background.

Given at http://www.lfpug.com in London on 26 March 2009.

Published in: Technology, News & Politics
4 Comments
51 Likes
Statistics
Notes
No Downloads
Views
Total Views
38,640
On Slideshare
0
From Embeds
0
Number of Embeds
15
Actions
Shares
0
Downloads
538
Comments
4
Likes
51
Embeds 0
No embeds

No notes for slide

iPhone Coding For Web Developers

  1. 1. iPhone coding for web developers Matt Biddulph www.hackdiary.com
  2. 2. From websites to mobile apps
  3. 3. www.twitter.com
  4. 4. m.twitter.com
  5. 5. Twitterifc, Tweetie and Twitterfon
  6. 6. www.facebook.com
  7. 7. m.facebook.com
  8. 8. native iPhone app
  9. 9. Joe Hewitt on the native Facebook app
  10. 10. “People must have assumed that all I had to do was plug Facebook's data into Apple's ready-to-use UI components and hit the GO button. Joe Hewitt on the native Facebook app
  11. 11. “I wish it had been that easy, but unfortunately many of the components I needed were missing from the iPhone SDK, even though they existed in Apple's own apps.” Joe Hewitt on the native Facebook app
  12. 12. Phonegap
  13. 13. Building native internet apps
  14. 14. Internet app basics
  15. 15. Internet app basics HTTP JSON or XML Regular Expressions Local storage
  16. 16. HTTP NSURLRequest is fiddly. I use GTMHTTPFetcher from Google Toolbox for Mac. http://code.google.com/p/google-toolbox-for-mac/ or TTURLRequest from Joe Hewitt http://joehewitt.com/post/the-three20-project/
  17. 17. XML Mac OS X has NSXMLDocument for DOM parsing. The iPhone only has NSXML for SAX parsing. This is hard.
  18. 18. XML iPhone ships with libxml2. It is good, fast and has a nasty C API. Convenience wrapper functions make it much easier: NSArray *PerformXMLXPathQuery(NSData *document, NSString *query); http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html
  19. 19. JSON Objective C coders make liberal use of mix-ins. Ruby coders fondly call this ‘monkeypatching’. #import quot;NSString+SBJSON.hquot; [@quot;{quot;1quot;:2}quot; JSONValue]; (returns an NSDictionary)
  20. 20. Regular Expressions Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems. —usually attributed to jwz in comp.lang.emacs
  21. 21. Regular Expressions Again, the iPhone’s string handling has no regular expression builtins. But it ships with the ICU library that does.
  22. 22. Regular Expressions RegexKitLite extends NSString with methods that bridge to ICU. This gives you UTF-safe functions with small memory overhead and caching. http://regexkit.sourceforge.net/RegexKitLite/
  23. 23. Regular Expressions As usual with Objective C, the method names are rather verbose. split: componentsSeparatedByRegex gsub: stringByReplacingOccurrencesOfRegex backrefs: matchEnumeratorWithRegex
  24. 24. Local Storage SQLite is the iPhone’s default database management library. This is a good thing.
  25. 25. Local Storage Yet again, it’s a C library that isn’t integrated with Cocoa.
  26. 26. Local Storage FMDB is an Objective C wrapper modeled on Java’s JDBC. It’s sensible. FMDatabase* db = [FMDatabase databaseWithPath:@quot;...quot;]; [db open]; [db executeUpdate:@”SELECT ...”]; http://code.google.com/p/flycode/source/browse/trunk/fmdb
  27. 27. A few words about event-driven code
  28. 28. The user is in control
  29. 29. UI responsiveness and rendering is a priority
  30. 30. Fallacies of networked computing
  31. 31. Fallacies of networked computing The network is reliable. Latency is zero. Bandwidth is infinite.
  32. 32. The world is asynchronous But threads are hard
  33. 33. Understand delegation
  34. 34. thank you Matt Biddulph www.hackdiary.com Flickr photo heroes: http://www.flickr.com/photos/scobleizer/1215753803/ http://www.flickr.com/photos/envision/3085397880/ http://www.flickr.com/photos/frinky/3236718934/ http://www.flickr.com/photos/nickbilton/2861938380/ http://www.flickr.com/photos/donsolo/2855854548/ http://www.flickr.com/photos/en321/209425860/ http://www.flickr.com/photos/mastrobiggo/2424561037/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×