Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Downloadable code examples for my books, "Programming iOS 8" and "iOS 7 Programming Fundamentals".
branch: master
Failed to load latest commit information.
bk1ch12p350notificationLeaker oops, runs now
bk1ch12p351timerLeaker timer leaker examples converted to Swift
bk1ch12p351timerLeaker2 timer leaker examples converted to Swift
bk1ch13p380kvo ooops, add comment about crashing if we go out of existence still obs…
bk2ch01p006customWindowInStoryboardApp update for 6.0.1 (app delegate method signature)
bk2ch01p012frame update for 6.0.1 (app delegate method signature)
bk2ch01p013bounds update for 6.0.1 (app delegate method signature)
bk2ch01p017transform update for 6.0.1 (app delegate method signature)
bk2ch01p024autoresizing update for 6.0.1 (app delegate method signature)
bk2ch01p031constraints update for 6.0.1 (app delegate method signature)
bk2ch01p032constraintSwapping update for 6.0.1 (app delegate method signature)
bk2ch01p032constraintSwapping2 added second version of example, using activateConstraints instead of…
bk2ch01p033layoutMargins new example showing layout margins
bk2ch01p038constraintsInequalitiesAndPriorities update for seed 7; update for margin change; don't use hard-coded ass…
bk2ch01p038evenDistribution update for 6.1
bk2ch01p039conditionalConstraints remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch01p040sizeClasses update for 6.1
bk2ch01p041constraintSwapping2 update for 6.1
bk2ch01p041designableView remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch01p045constraintsOrderOfEvents remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch01p046transformsAndConstraints remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch01p046transformsAndConstraints2 updated for seed 4 (IBOutlet syntax change, public, some at-signs rem…
bk2ch02p050HiResTest2 update for 6.1
bk2ch02p051ImageAndTraitCollection update for 6.1
bk2ch02p052mars update for 6.1
bk2ch02p053marsResizable update for 6.1
bk2ch02p056marsSlicing versioning foo
bk2ch02p057imageRendering update for 6.1
bk2ch02p059sixBlueCircles remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch02p061imageDrawing update for 6.1
bk2ch02p070filters update for 6.1
bk2ch02p070filters2 remove unnecessary extra private properties
bk2ch02p071BlurAndVibrancy minor (comments, formatting, etc.)
bk2ch02p077drawingInUIView minor (comments, formatting, etc.)
bk2ch02p086drawingInUIView2 updated chapter 2 examples for Swift seed 5
bk2ch02p088clearRect update for seed 7; draw a small square instead of a large rectangle
bk2ch03p095layerHierarchy update for 6.1
bk2ch03p101drawingIntoLayer remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch03p108compass remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch03p112layerDepth remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch03p113transformLayer1 eliminate explicit import of QuartzCore; in seed 7, this is imported …
bk2ch03p114transformLayer2 remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch03p116maskUtility minor
bk2ch03p117maskUtilityView update for 6.0.1 (app delegate method signature)
bk2ch04p125imageViewAnimation minor, get rid of some now unnecessary unwraps / casting
bk2ch04p130viewAnimation make count mean count by comparing to 1 instead of 0
bk2ch04p132viewAnimationFacade also deploy on iOS 7 just to prove that this trick is backwards compa…
bk2ch04p133cancelAnimation rearrange cases and make deployment target iOS 7, so you can test cha…
bk2ch04p133cancelAnimation2 foo
bk2ch04p133cancelAnimation3 same as the preceding example, but we store state in the layer rather…
bk2ch04p134springing remove nonfunctional options
bk2ch04p135keyFrameViewAnimation update for 6.1
bk2ch04p137transition minor formatting
bk2ch04p138transition2 updated for seed 4 (IBOutlet syntax change, public, some at-signs rem…
bk2ch04p148layerAnimation minor, tighter
bk2ch04p149keyframeSprite minor, get rid of some now unnecessary unwraps / casting
bk2ch04p151customAnimatableProperty remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch04p153groupedAnimation update for 6.1
bk2ch04p157layerTransition update for 6.1
bk2ch04p160frozenAnimation update for 6.0.1 (app delegate method signature)
bk2ch04p164actions update for 6.1
bk2ch04p165customAnimatableProperty2 remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch04p166emitThis minor logging, comments, simplifications
bk2ch04p172CIFilterAnimation minor logging, comments, simplifications
bk2ch04p175dynamics update for 6.1
bk2ch04p177dynamics2 good place to use unowned instead of weak, now that it doesn't crash
bk2ch04p183animationAndAutolayout one more little example showing snapshotting as a temporary solution
bk2ch04p183animationAndAutolayout2 updated for seed 4 (IBOutlet syntax change, public, some at-signs rem…
bk2ch04p183animationAndAutolayout3 new example showing animation of layout after dramatic change of cons…
bk2ch05p194touches minor, added logging to show that locationInView for window (nil) has…
bk2ch05p203gestureRecognizers remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch05p204dragByAttachment update for 6.1
bk2ch05p206gestureRecognizerDelegate update for 6.1
bk2ch05p207gestureRecognizersNib update for 6.1
bk2ch05p210hitTesting update for 6.1
bk2ch05p211compassTappable remove a bunch of parameter exclamation marks I think are wrong (most…
bk2ch05p212hitTestingDistortedLayer update for 6.1
bk2ch05p213hitTestingDuringAnimation whole new way of hit-testing an animated view (thanks, Apple!)
bk2ch05p216exclusiveTouch update for 6.1
bk2ch05p217dependency update for 6.1
bk2ch06p236manualViewController update for 6.0.1 (app delegate method signature)
bk2ch06p237manualViewController2 update for 6.0.1 (app delegate method signature)
bk2ch06p239nibViewController update for 6.1
bk2ch06p239nibViewControllerWorkaround1 update for 6.0.1 (app delegate method signature)
bk2ch06p239nibViewControllerWorkaround2 update for 6.0.1 (app delegate method signature)
bk2ch06p239nibViewControllerWorkaround3 update for 6.0.1 (app delegate method signature)
bk2ch06p239nibViewControllerWorkaround4 update for 6.0.1 (app delegate method signature)
bk2ch06p239nibViewControllerWorkaround4Universal update for 6.0.1 (app delegate method signature)
bk2ch06p239nibViewControllerWorkaround5 update for 6.0.1 (app delegate method signature)
bk2ch06p242nibInstantiatedViewController update for 6.1 final
bk2ch06p243storyboardInstantiatedViewController update for 6.1
bk2ch06p250sizeChangeTest further test to see what happens if we implement deprecated rotation …
bk2ch06p253orientationsPermitted update for 6.1
bk2ch06p253orientationsPermitted2 update for 6.1
bk2ch06p253orientationsPermitted3 update for 6.1
bk2ch06p253orientationsPermitted4 update for 6.1
bk2ch06p255rotationChangesInterface added launch screen xibs to some projects that use traitCollection ex…
bk2ch06p256rotationChangesInterface2 added launch screen xibs to some projects that use traitCollection ex…
bk2ch06p257rotationChangesInterface3 update for 6.1
bk2ch06p258launchIntoRotationEvents update for 6.1
bk2ch06p259launchIntoRotation minor: more logging, formatting
bk2ch06p264presentedViewController more logging
bk2ch06p264presentedViewControllerAdaptive new example gently introducing adaptive presentation
bk2ch06p265presentedViewControllerStoryboard use class protocol instead of objc protocol which is overkill
bk2ch06p270modalPresentationContext update for 6.0.1, more logging and options for testing
bk2ch06p272forcedRotation use class protocol instead of objc protocol which is overkill
bk2ch06p273rotationCausesPresentation updated chapter 6 examples to deal with huge seed 5 change (bug or de…
bk2ch06p275tabbedInterface more minor, shorter
bk2ch06p281navigationInterface update for 6.1
bk2ch06p282navigationInterfaceStoryboard update for 6.1
bk2ch06p292customAnimation1 simplify by two lines
bk2ch06p296customAnimation2 simplify by two lines
bk2ch06p300customAnimation3 fix dumb bug (remember to nilify outmoded transition context when don…
bk2ch06p301customAnimation4 update for 6.0.1 (app delegate method signature)
bk2ch06p302addingPresentationController update for 6.1
bk2ch06p304customPresentedAnimation2 update for 6.0.1
bk2ch06p311pageController remove unnecessary exclamation marks, remove unnecessary code
bk2ch06p313pageControllerBug update for 6.0.1
bk2ch06p316containerController update for 6.1 final, nil animations block now okay
bk2ch06p319containerControllerConstraints updated chapter 6 examples for Swift seed 5
bk2ch06p320containerControllerCustomAnimation updated chapter 6 examples to deal with huge seed 5 change (bug or de…
bk2ch06p321overrideTraitCollection new example showing basic trait collection override
bk2ch06p322containerControllerSizeMessaging work around inability to notify child of size change in Swift
bk2ch06p324containerViewControllerStoryboard minor, get rid of some now unnecessary unwraps / casting
bk2ch06p326unwindWithCustomParent extra logging to test event forwarding (for later in the chapter)
bk2ch06p327unwind update for 6.1 final
bk2ch06p327unwind2 update for 6.1 final
bk2ch06p332eventIncoherencies update for 6.1
bk2ch06p334containerEventForwarding update for 6.1 final, nil animations block now okay
bk2ch06p336memoryWarning explicit nil initialization because Swift can get buggy about initial…
bk2ch06p341SimplestRestorationExample update for 6.1 final
bk2ch06p347SimplestRestorationExample2 improve logging, test window restoration id
bk2ch06p351pageControllerRestoration update for 6.1
bk2ch06p352pageControllerRestoration2 update for 6.1 final
bk2ch06p353pageControllerRestoration3 update for 6.1 final
bk2ch06p356saveAndRestoreArbitraryObject update for 6.1
bk2ch07p360scrollViewInCode more logging
bk2ch07p362scrollViewInCode2 converted first three scroll view examples (chapter 7) to swift, adde…
bk2ch07p363scrollViewInCode3 update for 6.1
bk2ch07p363scrollViewInCode4 updated chapter 7 examples for Swift seed 5
bk2ch07p366scrollViewInNib foo
bk2ch07p367scrollViewInNibAutolayout update for 6.1
bk2ch07p367scrollViewInNibAutolayout2 update for 6.1
bk2ch07p367scrollViewInNibAutolayout3 updated chapter 7 examples for Swift seed 5
bk2ch07p370contentInset continuing to convert chapter 7 examples to swift (and to encounter t…
bk2ch07p370contentInset2 continuing to convert chapter 7 examples to swift (and to encounter t…
bk2ch07p370contentInset3 update for 6.1
bk2ch07p372paging update for 6.0.1
bk2ch07p374scrollWithTiling minor, neater code
bk2ch07p375zoom more logging
bk2ch07p376zoomCentered update for 6.0.1
bk2ch07p376zoomCentered2 remove logging
bk2ch07p376zoomCentered3 new example, same as previous but proving that it works under autolayout
bk2ch07p378zoomDetailed update for 6.1
bk2ch07p378zoomDetailed2 update for 6.1
bk2ch07p383dragInScrollView update for 6.1
bk2ch07p384dragInScrollView2 update for 6.1
bk2ch08p398cellBackgroundLayering update code for Xcode 6.2, the exclamation marks are back
bk2ch08p402overrideCellLayout update code for Xcode 6.2, the exclamation marks are back
bk2ch08p403addCellSubviewsInCode update for 6.1
bk2ch08p405addCellSubviewsInNib update for 6.1 final
bk2ch08p406addCellSubviewsNibOutlets update for 6.1 final
bk2ch08p407addCellSubviewsInStoryboard update for 6.1
bk2ch08p411individualCells update for 6.1
bk2ch08p412SimplestDataSource update code for Xcode 6.2, the exclamation marks are back
bk2ch08p416sections update code for Xcode 6.2, the exclamation marks are back
bk2ch08p424variableHeights update for 6.1 final
bk2ch08p431pickACell update code for Xcode 6.2, the exclamation marks are back
bk2ch08p438searchableTable update code for Xcode 6.2, the exclamation marks are back
bk2ch08p438searchableTable2 update code for Xcode 6.2, the exclamation marks are back
bk2ch08p438searchableTable3 more minor, shorter
bk2ch08p445deleteTableRows update code for Xcode 6.2, the exclamation marks are back
bk2ch08p446rowActions update code for Xcode 6.2, the exclamation marks are back
bk2ch08p447editInsertAndRearrangeRows minor, tighter
bk2ch08p451dynamicTableContent update code for Xcode 6.2, the exclamation marks are back
bk2ch08p453tableCellMenus update code for Xcode 6.2, the exclamation marks are back
bk2ch08p454tableCellMenus2 update code for Xcode 6.2, the exclamation marks are back
bk2ch08p460collectionViewCellBackgroundLayering update code for Xcode 6.2, the exclamation marks are back
bk2ch08p462collectionViewFlowLayout update code for Xcode 6.2, the exclamation marks are back
bk2ch08p466collectionViewFlowLayout2 update code for Xcode 6.2, the exclamation marks are back
bk2ch08p467collectionViewLayoutFromScratchObjc split last example of chapter 8 into two, one in Swift (prohibitively…
bk2ch08p467collectionViewLayoutFromScratchSwift update code for Xcode 6.2, the exclamation marks are back
bk2ch09p476popovers update code for Xcode 6.2, the exclamation marks are back
bk2ch09p477popoversOnPhone minor, comment out alternate adaptive choice
bk2ch09p481popoverInStoryboard update code for Xcode 6.2, the exclamation marks are back
bk2ch09p485PopoverPresentingViewController new example showing presented-in-popover bug and workaround
bk2ch09p487searchInPopover update code for Xcode 6.2, the exclamation marks are back
bk2ch09p488basicMasterDetail update code for Xcode 6.2, the exclamation marks are back
bk2ch09p488universalSplitViewControllerStoryboardTemplateAnalysis update code for Xcode 6.2, the exclamation marks are back
bk2ch09p489universalSplitViewControllerStoryboard2 update code for Xcode 6.2, the exclamation marks are back
bk2ch09p490universalSplitViewControllerManual update for 6.1 final
bk2ch10p495TableWithDynamicType update code for Xcode 6.2, the exclamation marks are back
bk2ch10p495dynamicType more minor, shorter
bk2ch10p497downloadableFonts update for 6.1
bk2ch10p498fontDescriptor update for 6.1
bk2ch10p499fontDescriptor2 converted second font descriptor example
bk2ch10p503attributedString update for 6.1
bk2ch10p504RTFImportTest new example illustrating importing attributed string from standard fo…
bk2ch10p507tabStops update for 6.1 final
bk2ch10p508AttributedTextAsSecretMarking nicer formatting
bk2ch10p509attributedStringDrawing playing around with more string drawing context features
bk2ch10p510attributedStringDrawing2 update for 6.1 final
bk2ch10p512labelBreaking update for 6.1
bk2ch10p513selfSizingLabel update for 6.0.1 (app delegate method signature)
bk2ch10p513selfSizingLabel2 update to illustrate autosizing label introduced in iOS 7, remove unn…
bk2ch10p514labelFontSizeScaling update for 6.1
bk2ch10p520textFieldSliding code cleanup, removing commented-out code left in only to remind myse…
bk2ch10p522textFieldScrollView eliminate more unused code
bk2ch10p524keyboardAccessory update for 6.1 final
bk2ch10p526textFieldDelegate update for 6.1 final
bk2ch10p531selfSizingTextView update for 6.1
bk2ch10p532textViewAndKeyboard match scroll view code from earlier
bk2ch10p536exclusionPath update for 6.1
bk2ch10p537exclusionPath2 update for 6.1
bk2ch10p539textKitStacks update for 6.1
bk2ch10p541textLayoutGeometry update for 6.1
bk2ch10p543drawingWithTextKit update for 6.1
bk2ch11p551webview update for 6.1 final
bk2ch11p552webkit update for 6.1 final
bk2ch11p553webkit2 update for 6.1 final
bk2ch12p564timeConsumingNavigation update code for Xcode 6.2, the exclamation marks are back
bk2ch12p566customThermometer more minor, shorter
bk2ch12p568pickerView update for 6.1
bk2ch12p573searchBarFromHell update for 6.1
bk2ch12p580stepper update for 6.1
bk2ch12p585slider minor, coerce in a nicer spot
bk2ch12p589segmentedControl update for 6.1
bk2ch12p595button update for 6.1, work around attributed string underlining bug
bk2ch12p597knob remove redundant rotation
bk2ch12p602toolbarShadowBug update for 6.1 final
bk2ch12p606navigationBar update for 6.1 final
bk2ch12p609tabBar update for 6.1, be so much cooler and swiftier
bk2ch12p611tabBarMore update code for Xcode 6.2, the exclamation marks are back
bk2ch13p620dialogsOniPhone update for 6.1 final, improve example to be universal, better demonst…
bk2ch13p624actionSheetPopovers update for 6.1 final, improve example to be universal, better demonst…
bk2ch13p630localNotification okay, that didn't work; register in both places instead
bk2ch13p631todayExtension revise example, empty the app to concentrate on the extension, better…
bk2ch13p635activityView update for 6.1 final
bk2ch13p636actionExtension update for 6.1 final
bk2ch14p640systemSound small letter for function name
bk2ch14p643ducking use class protocol instead of objc protocol which is overkill
bk2ch14p653backgroundPlayerAndInterrupter use class protocol instead of objc protocol which is overkill
bk2ch14p655AVAudioEngineTest minor, rename variable
bk2ch14p656textToSpeech update for seed 6
bk2ch15p659SimplestAVKit break AVKit intro into multiple examples
bk2ch15p660EmbeddedAVKit improve use of KVO
bk2ch15p661EmbeddedAVKit2 break AVKit intro into multiple examples
bk2ch15p669playerLayer update for 6.1 final
bk2ch15p672AVKit update for 6.1 final
bk2ch15p673onlyOne prove that two movies can play simultaneously
bk2ch16p678mediaQuery code cleanup
bk2ch16p687AVQueuePlayer update code for Xcode 6.2, the exclamation marks are back
bk2ch16p690mediaPicker update for 6.1 final, use property names rather than strings, tweak m…
bk2ch17p697pickaMovieOrPhoto better casting of fetched dictionary values
bk2ch17p699photoKitData update for 6.1 final, nicer logging, better behaved on iPad
bk2ch17p700PhotoKitImages use class protocol instead of objc protocol which is overkill
bk2ch17p702takeAPicture better casting of fetched dictionary values
bk2ch17p704takeAPicture2 better casting of fetched dictionary values
bk2ch17p707takeAPicAVFoundation minor (reverse code order)
bk2ch18p713addressBook still tweaking that authorization stuff; update for 6.1 final
bk2ch19p725calendar replace deprecated gregorian
bk2ch19p731reminders replace deprecated gregorian
bk2ch20p740social update for 6.1 final
bk2ch21p744maps update to 6.1 final, remove MKMapRectMake workaround; restore Objecti…
bk2ch21p761userLocationAndGeocoding ooooh, turns out I can comment out one line of code
bk2ch22p773location stylistic, use self for manager property
bk2ch22p775heading stylistic, use self for manager property
bk2ch22p780shake update for 6.1 final
bk2ch22p782lyingDown update for 6.1 final
bk2ch22p784smackMe explicit nil initialization because Swift can get buggy about initial…
bk2ch22p787gyro converted more chapter 22 examples to Swift
bk2ch22p789attitudeRotation update for 6.1 final
bk2ch22p790motionActivity update code for Xcode 6.2, the exclamation marks are back
bk2ch23p798basicFileOperations remove unnecessary NSCopying
bk2ch23p802fileHandoff update code for Xcode 6.2, the exclamation marks are back
bk2ch23p809peopleGroups remove unnecessary NSCopying
bk2ch23p818xml remove unnecessary NSCopying
bk2ch23p821SQLite use latest version of fmdb
bk2ch23p824peopleGroupsCoreData update code for Xcode 6.2, the exclamation marks are back
bk2ch23p829imageIO update for 6.1 final, and now we have to cast to string to use CFStri…
bk2ch24p834simpleHTTP update to 6.1 final
bk2ch24p837lessSimpleHTTP update to 6.1 final
bk2ch24p838lessSimpleHTTP2 update to 6.1 final
bk2ch24p842downloader update code for Xcode 6.2, the exclamation marks are back
bk2ch24p846backgroundDownload update for 6.1 final
bk2ch24p853bonjour minor, formatting for book
bk2ch25p860mandelbrotNoThreading minor, clean up formatting, clearer comments
bk2ch25p865mandelbrotOperation explicit nil initialization because Swift can get buggy about initial…
bk2ch25p868mandelbrotGCD minor, code cleanup and formatting
bk2ch26p878undoableDrag minor, comment out unused lines
bk2ch26p878undoableDrag2 minor, comment out unused lines
iOS6bookExamples moved iOS 6 book examples into a subfolder
iOS7bookExamples copy iOS 7 book examples off to their own folder
README.md updated readme
iOS4bookExamples.zip retire iOS 4 and iOS 5 book examples into zip archives
iOS5bookExamples.zip retire iOS 4 and iOS 5 book examples into zip archives

README.md

These are the complete downloadable code examples for my books, Programming iOS 8 (http://shop.oreilly.com/product/0636920034261.do) — now revised for iOS 8 (and Swift) — and iOS 7 Programming Fundamentals (http://shop.oreilly.com/product/0636920032465.do).

The Swift language keeps changing and occasionally breaks some of the examples, but they were all correct the last time I looked. If there's a problem, it's likely just an exclamation mark or something that needs to be added; I'm sure you can figure it out until I get around to fixing it.

If you find these examples helpful and you haven't purchased the books, please consider doing so.

The downloadable code and screenshots for the previous editions have been moved off to subfolders "iOS7bookExamples" and "iOS6bookExamples". The code for the earlier editions have been archived as "iOS5bookExamples.zip" and "iOS4bookExamples.zip".

Matt Neuburg

Something went wrong with that request. Please try again.