Your SlideShare is downloading. ×
  • Like
  • Save
How Do You Do That On iPhone? [CodeMash 2010]
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

How Do You Do That On iPhone? [CodeMash 2010]

  • 3,215 views
Published

If you've used iPhone OS applications, you've no doubt seen a number of common tricks that are in no way obvious from looking at the documentation provided in the SDK. In this session, we'll look at a …

If you've used iPhone OS applications, you've no doubt seen a number of common tricks that are in no way obvious from looking at the documentation provided in the SDK. In this session, we'll look at a grab-bag of some of the most popular and least obvious techniques you'll want in your developer's toolkit.

Published in Technology , News & Politics
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,215
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
4

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. HOW DO I DO THAT ON IPHONE? Chris Adamson CodeMash 2010
  • 2. AGENDA Table tricks Media mastery Tsundere tools Miscellania
  • 3. TABLE TRICKS
  • 4. SORTING TABLES WITH KVC
  • 5. SORTING ARRAYS NSSortDescriptor works nicely with key-value-coding Values need to implement compare: Alternatives sortedArrayUsingSelector: - called on value sortedArrayUsingFunction:context: - calls a C function
  • 6. CUSTOM TABLE CELLS
  • 7. CUSTOM TABLE CELLS Cell goes in its own nib, connected to an outlet in an owner Owner uses this outlet when creating new cells Find subviews of cell by tag, or subclass UITableViewCell and set up outlets and properties.
  • 8. TABLE FILTERS
  • 9. TABLE FILTERING IB provides “Search Bar and Search Display Controller” UISearchBar and a UITable that slides in to show filter results. You implement UISearchBarDelegate
  • 10. TOO MUCH MORE! Tweetie 2 - pull-to-reload http://github.com/enormego/ EGOTableViewPullRefresh http://www.drobnik.com/touch/2009/12/how-to- make-a-pull-to-reload-tableview-just-like-tweetie-2/ Controls in tables - see Apple’s table guide
  • 11. MEDIA MASTERY
  • 12. VIBRATION IS A “SOUND”?
  • 13. VIBRATION AudioServicesPlaySystemSound (kSystemSoundID_Vibrate); Does nothing on iPod touch AudioServicesPlayAlertSound with a SystemSoundID may also vibrate, if user has vibrate-on-ring set
  • 14. PLAYING NICE WITH IPOD
  • 15. PLAYING NICE WITH IPOD Use AVAudioSession categories to set behavior AVAudioSessionCategoryAmbient AVAudioSessionCategorySoloAmbient AVAudioSessionCategoryPlayback AVAudioSessionCategoryRecord AVAudioSessionCategoryPlayAndRecord AVAudioSessionCategoryAudioProcessing
  • 16. PLAYING NICE WITH IPOD Core Audio uses same categories, different names kAudioSessionCategory_AmbientSound kAudioSessionCategory_SoloAmbientSound kAudioSessionCategory_MediaPlayback kAudioSessionCategory_RecordAudio kAudioSessionCategory_PlayAndRecord kAudioSessionCategory_AudioProcessing
  • 17. HANDLING INTERRUPTIONS
  • 18. HANDLING INTERRUPTIONS Can be from alarms, incoming calls, etc. If accepted, your app terminates AVAudioSessionDelegate beginInterruption, endInterruption Core Audio makes you set an interruption callback when you InitializeAudioSession App-level is different: applicationWillResignActive: and applicationWillTerminate:
  • 19. TSUNDERE TOOLS
  • 20. “TSUNDERE” ( )
  • 21. KEYCHAIN
  • 22. KEYCHAIN ON IPHONE No access to a system-wide keychain Apps get access to their own items only (well…) Four essential C functions: SecItemAdd, SecItemDelete, SecItemUpdate, SecItemCopyMatching All are a huge hassle to call
  • 23. KEYCHAIN FTW! Keychain items survive application wipes and reinstalls Keychain is encrypted, and backed up by iTunes Works with untyped void* data types You can put whatever you like in a keychain item
  • 24. KEYCHAIN FTW 2! Can share data between applications with Keychain Create Entitlements file with a keychain-access-group that matches first fragment of your apps’ identifiers. Use key kSecAttrAccessGroup in keychain calls Use same signing credentials That said… I couldn’t get this working in time
  • 25. XCODE
  • 26. BUILDING “LITE” VERSIONS
  • 27. BUILDING “LITE” VERSIONS Create multiple targets Each target has different Info.plist and different build settings Potentially different Icon.png, MainWindow.xib, etc. Can omit resource files from your lite version Set OTHER_CFLAGS to do #ifdef
  • 28. COMMAND-LINE BUILDS
  • 29. COMMAND-LINE BUILDS /usr/bin/xcodebuild builds project in current directory with current settings. Can build any or all targets, supports different SDKs (iPhone 2.2 / 3.0 / 3.1), and configurations (Debug / Release) Only on Mac Buy an XServe for your build farm
  • 30. CREATING .CAF FILES
  • 31. /USR/BIN/AFCONVERT Reads and writes all default Core Audio formats Useful for converting into .caf format (preferred format for iPhone audio files) and transcoding (no floating-point PCM samples on iPhone) Getting the arguments right can be tough afconvert -d LEI16 -f 'caff' orig-cymbal.caf
  • 32. MISCELLANIA
  • 33. HOW TO GET YOUR NETWORK APP REJECTED
  • 34. NETWORK REACHABILITY Create SCNetworkReachabilityRef Call SCNetworkReachabilityGetFlags with address you intend to connect to Call SCNetworkReachabilitySetCallback to get callbacks when this value changes Mask off the results
  • 35. USEFUL REACHABILITY FLAGS Good: kSCNetworkReachabilityFlagsReachable, Probably OK: kSCNetworkReachabilityFlagsConnectionRequired, kSCNetworkReachabilityFlagsConnectionOnTraffic, kSCNetworkReachabilityFlagsConnectionOnDemand How to know you’re not on wi-fi: kSCNetworkReachabilityFlagsIsWWAN
  • 36. MAKE NETWORK FAST URL Loading System quietly supports gzip and deflate You just get the decoded data NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:postURL]; [request setHTTPMethod: @"POST"]; [request addValue:@"gzip" forHTTPHeaderField:@"Accepts-Encoding"];
  • 37. MORE… Prepared exclusively for Chris Adamson
  • 38. CONTACT Me: http://www.subfurther.com/ @invalidname invalidname@gmail iPhone SDK Development book http://www.pragprog.com/