SlideShare ist ein Scribd-Unternehmen logo
1 von 38
HOW DO I DO THAT ON
     IPHONE?
      Chris Adamson
      CodeMash 2010
AGENDA


Table tricks

Media mastery

Tsundere tools

Miscellania
TABLE TRICKS
SORTING TABLES WITH KVC
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
CUSTOM TABLE CELLS
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.
TABLE FILTERS
TABLE FILTERING


IB provides “Search Bar and
Search Display Controller”

  UISearchBar and a UITable that
  slides in to show filter results.

  You implement
  UISearchBarDelegate
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
MEDIA MASTERY
VIBRATION IS A “SOUND”?
VIBRATION


AudioServicesPlaySystemSound
(kSystemSoundID_Vibrate);

Does nothing on iPod touch

AudioServicesPlayAlertSound with a SystemSoundID
may also vibrate, if user has vibrate-on-ring set
PLAYING NICE WITH IPOD
PLAYING NICE WITH IPOD

Use AVAudioSession categories to set behavior
  AVAudioSessionCategoryAmbient

  AVAudioSessionCategorySoloAmbient

  AVAudioSessionCategoryPlayback

  AVAudioSessionCategoryRecord

  AVAudioSessionCategoryPlayAndRecord

  AVAudioSessionCategoryAudioProcessing
PLAYING NICE WITH IPOD

Core Audio uses same categories, different names
  kAudioSessionCategory_AmbientSound

  kAudioSessionCategory_SoloAmbientSound

  kAudioSessionCategory_MediaPlayback

  kAudioSessionCategory_RecordAudio

  kAudioSessionCategory_PlayAndRecord

  kAudioSessionCategory_AudioProcessing
HANDLING INTERRUPTIONS
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:
TSUNDERE TOOLS
“TSUNDERE” (   )
KEYCHAIN
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
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
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
XCODE
BUILDING “LITE” VERSIONS
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
COMMAND-LINE BUILDS
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
CREATING .CAF FILES
/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
MISCELLANIA
HOW TO GET YOUR
NETWORK APP REJECTED
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
USEFUL REACHABILITY FLAGS

Good: kSCNetworkReachabilityFlagsReachable,

Probably OK:
kSCNetworkReachabilityFlagsConnectionRequired,
kSCNetworkReachabilityFlagsConnectionOnTraffic,
kSCNetworkReachabilityFlagsConnectionOnDemand

How to know you’re not on wi-fi:
kSCNetworkReachabilityFlagsIsWWAN
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"];
MORE…




Prepared exclusively for Chris Adamson
CONTACT

Me:

 http://www.subfurther.com/

 @invalidname

 invalidname@gmail

iPhone SDK Development book

 http://www.pragprog.com/

Weitere ähnliche Inhalte

Andere mochten auch

А эффективен ли сайт?
А эффективен ли сайт?А эффективен ли сайт?
А эффективен ли сайт?
Usanov Aleksey
 
CLA Social Presentation 11
CLA Social Presentation 11CLA Social Presentation 11
CLA Social Presentation 11
Brian Barela
 
SC Hospital Association Presentation: Health Care Reform - What Does It Mean ...
SC Hospital Association Presentation: Health Care Reform - What Does It Mean ...SC Hospital Association Presentation: Health Care Reform - What Does It Mean ...
SC Hospital Association Presentation: Health Care Reform - What Does It Mean ...
Katherine Swartz Hilton
 
Isolation of genes differentially expressed during the defense response of Ca...
Isolation of genes differentially expressed during the defense response of Ca...Isolation of genes differentially expressed during the defense response of Ca...
Isolation of genes differentially expressed during the defense response of Ca...
CIAT
 
Departamento De CiêNcias Da EducaçãO
Departamento De CiêNcias Da EducaçãODepartamento De CiêNcias Da EducaçãO
Departamento De CiêNcias Da EducaçãO
catherineee
 
Indenização das empresas urbs
Indenização das empresas   urbsIndenização das empresas   urbs
Indenização das empresas urbs
Professora Josete
 
Yahoo Hack Day
Yahoo Hack DayYahoo Hack Day
Yahoo Hack Day
e27
 
Gene discovery application_rice
Gene discovery application_riceGene discovery application_rice
Gene discovery application_rice
CIAT
 
Pensamentos e reflexões em 2011
Pensamentos e reflexões em 2011Pensamentos e reflexões em 2011
Pensamentos e reflexões em 2011
Aclecio Dantas
 
RRT 2010 - MicroEnsure on Microinsurance
RRT 2010 - MicroEnsure on MicroinsuranceRRT 2010 - MicroEnsure on Microinsurance
RRT 2010 - MicroEnsure on Microinsurance
MABSIV
 
2011 02 megapolisering stipo
2011 02 megapolisering stipo2011 02 megapolisering stipo
2011 02 megapolisering stipo
Stipo
 

Andere mochten auch (20)

Citrix Vision And Strategy Oct 2009
Citrix Vision And Strategy Oct 2009Citrix Vision And Strategy Oct 2009
Citrix Vision And Strategy Oct 2009
 
А эффективен ли сайт?
А эффективен ли сайт?А эффективен ли сайт?
А эффективен ли сайт?
 
CLA Social Presentation 11
CLA Social Presentation 11CLA Social Presentation 11
CLA Social Presentation 11
 
SC Hospital Association Presentation: Health Care Reform - What Does It Mean ...
SC Hospital Association Presentation: Health Care Reform - What Does It Mean ...SC Hospital Association Presentation: Health Care Reform - What Does It Mean ...
SC Hospital Association Presentation: Health Care Reform - What Does It Mean ...
 
Escenario y cultura de la Web social + 10 pistas para medios que quieran cambiar
Escenario y cultura de la Web social + 10 pistas para medios que quieran cambiarEscenario y cultura de la Web social + 10 pistas para medios que quieran cambiar
Escenario y cultura de la Web social + 10 pistas para medios que quieran cambiar
 
Isolation of genes differentially expressed during the defense response of Ca...
Isolation of genes differentially expressed during the defense response of Ca...Isolation of genes differentially expressed during the defense response of Ca...
Isolation of genes differentially expressed during the defense response of Ca...
 
Webservices e Computação em Nuvem com PHP
Webservices e Computação em Nuvem com PHPWebservices e Computação em Nuvem com PHP
Webservices e Computação em Nuvem com PHP
 
Trading stockssemanal10062011
Trading stockssemanal10062011Trading stockssemanal10062011
Trading stockssemanal10062011
 
Departamento De CiêNcias Da EducaçãO
Departamento De CiêNcias Da EducaçãODepartamento De CiêNcias Da EducaçãO
Departamento De CiêNcias Da EducaçãO
 
Southlake Focus Group April LinkedIn Presentation
Southlake Focus Group April LinkedIn PresentationSouthlake Focus Group April LinkedIn Presentation
Southlake Focus Group April LinkedIn Presentation
 
2011 05 dag 2 masterclass opdrachtschouw, sfs, streefbeeld en strategie, scho...
2011 05 dag 2 masterclass opdrachtschouw, sfs, streefbeeld en strategie, scho...2011 05 dag 2 masterclass opdrachtschouw, sfs, streefbeeld en strategie, scho...
2011 05 dag 2 masterclass opdrachtschouw, sfs, streefbeeld en strategie, scho...
 
Indenização das empresas urbs
Indenização das empresas   urbsIndenização das empresas   urbs
Indenização das empresas urbs
 
1
11
1
 
Percorso professionale
Percorso professionalePercorso professionale
Percorso professionale
 
Yahoo Hack Day
Yahoo Hack DayYahoo Hack Day
Yahoo Hack Day
 
Gene discovery application_rice
Gene discovery application_riceGene discovery application_rice
Gene discovery application_rice
 
Test
TestTest
Test
 
Pensamentos e reflexões em 2011
Pensamentos e reflexões em 2011Pensamentos e reflexões em 2011
Pensamentos e reflexões em 2011
 
RRT 2010 - MicroEnsure on Microinsurance
RRT 2010 - MicroEnsure on MicroinsuranceRRT 2010 - MicroEnsure on Microinsurance
RRT 2010 - MicroEnsure on Microinsurance
 
2011 02 megapolisering stipo
2011 02 megapolisering stipo2011 02 megapolisering stipo
2011 02 megapolisering stipo
 

Mehr von Chris Adamson

Mehr von Chris Adamson (20)

Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)
Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)
Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)
 
Whatever Happened to Visual Novel Anime? (JAFAX 2018)
Whatever Happened to Visual Novel Anime? (JAFAX 2018)Whatever Happened to Visual Novel Anime? (JAFAX 2018)
Whatever Happened to Visual Novel Anime? (JAFAX 2018)
 
Media Frameworks Versus Swift (Swift by Northwest, October 2017)
Media Frameworks Versus Swift (Swift by Northwest, October 2017)Media Frameworks Versus Swift (Swift by Northwest, October 2017)
Media Frameworks Versus Swift (Swift by Northwest, October 2017)
 
Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...
Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...
Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...
 
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is FineCocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
 
Forward Swift 2017: Media Frameworks and Swift: This Is Fine
Forward Swift 2017: Media Frameworks and Swift: This Is FineForward Swift 2017: Media Frameworks and Swift: This Is Fine
Forward Swift 2017: Media Frameworks and Swift: This Is Fine
 
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
 
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
 
Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)
 
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
 
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
 
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
 
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
 
Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014
 
Stupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las VegasStupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las Vegas
 
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
 
Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)
 
Stupid Video Tricks
Stupid Video TricksStupid Video Tricks
Stupid Video Tricks
 
Introduction to the Roku SDK
Introduction to the Roku SDKIntroduction to the Roku SDK
Introduction to the Roku SDK
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

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

  • 1. HOW DO I DO THAT ON IPHONE? Chris Adamson CodeMash 2010
  • 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
  • 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.
  • 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
  • 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
  • 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
  • 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:
  • 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
  • 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
  • 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
  • 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
  • 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"];
  • 38. CONTACT Me: http://www.subfurther.com/ @invalidname invalidname@gmail iPhone SDK Development book http://www.pragprog.com/