The basics of programming native applications on the iPhone and iPod touch. Delivered as a session in Singapore PHP User Group meeting 3-Nov-2009.
Event URL: http://bit.ly/phpsgnov09
3. What do you need
Minimum Good to have
An Intel Mac with An iPhone or iPod
Leopard or Snow touch
Leopard
iPhone Developer
iPhone SDK (free membership
download)
A bank account
Some free time and (SWIFT)
patience
4. The iPhone Stack
Cocoa Touch WebKit
Objective-C Runtime Core*** Frameworks
ANSI C Runtime ANSI C++ Runtime OpenGL ES
Unix (BSD Variant), 32-bit ARM
9. What you can do
Floating-point math Network (TCP/IP) in & out
Threads Accelerated 3D graphics
C++ Programming Memory-mapped files —
BSD mmap()
STL included
Control iPod playback
Access the Address Book
(new in OS 3.0)
Compose e-mail
Write to the Photo Library
10. What you can’t do
Run in the background Intercept phone calls /
SMSs / e-mails
Forking / multitasking
Create self-modifying
Access the Calendar
code
Read user’s e-mail
Access other
application’s data area
13. JavaScript Object Notation (JSON)
{
"firstName": "John",
List of Values in "lastName": "Smith",
"address": {
JavaScript syntax "streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
Useful if you have a "postalCode": "10021"
},
JavaScript interpreter "phoneNumbers": [
ready { "type": "home",
"number": "212 555-1234" },
{ "type": "fax",
iPhone has one! ]
"number": "646 555-4567" }
}
14. JSON Example
Your iApp UIWebView Your Server
HTTP Request
JSON Response
JSON String
Data Values
15. Property List Talk
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
Apple’s first-class XML ! "http://www.apple.com/DTDs/
PropertyList-1.0.dtd">
format <plist version="1.0">
<dict>
<key>Year Of Birth</key>
<integer>1965</integer>
Can be easily <key>Pets Names</key>
<array/>
generated by a PHP <key>Picture</key>
<data>
script ! PEKBpYGlmYFCPA==
</data>
<key>City of Birth</key>
<string>Springfield</string>
Built-in conversion to <key>Name</key>
<string>John Doe</string>
Cocoa objects <key>Kids Names</key>
<array>
! <string>John</string>
NSDictionary* dic = [NSDictionary ! <string>Kyra</string>
dictionaryWithContentsOfURL:...]; </array>
</dict>
</plist>
16. HTTP-Plist Example
Your iApp NSDictionary Your Server
[NSDictionary dictionaryWithContentsOfURL:...]
HTTP Request
Property List response
new Dictionary object
17. Case Study: Fund Watch
Display fund prices from
Fundsupermart*
Screen scraper
JavaScript-based HTML
parser
Derived from
Fundsupermart
Dashboard Widget
*Fund Watch is not associated with Fundsupermart
18. Fund Watch Parser
Fund Watch UIWebView fundsupermart.com
Load JavaScript library
Request fund prices page
HTML Page
Parse HTML Page
Fund prices
19. The App Store
Accessible via iTunes
3rd party screen
scrapers
The only way to sell your
native apps
50K+ apps and counting
Requires a developer’s
account
20. Selling your Apps
1. Register for an iPhone Developer account
2. Get your bank’s SWIFT code
3. Prepare IRS documents
1. Fill and submit SS-4 “Request for EIN” to IRS
2. Wait for your EIN from IRS
3. Fill form W8-BEN and submit to Apple
4. Fill the Paid Applications Contract
5. Register SWIFT code to Apple
6. Upload your paid applications to Apple’s iTunes Connect
21. Beyond the App Store
Advertisement Admob
Analytics Pinch Media
Social Networking OpenFeint