CocoaProgrammingforOSX:TheBigNerdRanchGuide
byAaronHillegass,AdamPrebleandNateChandler
Copyright©2015BigNerdRanch,LLC.
Allrightsreserved.PrintedintheUnitedStatesofAmerica.Thispublicationisprotectedbycopyright,andpermissionmustbe
obtainedfromthepublisherpriortoanyprohibitedreproduction,storageinaretrievalsystem,ortransmissioninanyformorbyany
means,electronic,mechanical,photocopying,recording,orlikewise.Forinformationregardingpermissions,contact
BigNerdRanch,LLC.
200ArizonaAveNE
Atlanta,GA30307
(770)817-6373
http://www.bignerdranch.com/
book-comments@bignerdranch.com
The10-gallonhatwithpropellerlogoisatrademarkofBigNerdRanch,LLC.
ExclusiveworldwidedistributionoftheEnglisheditionofthisbookby
PearsonTechnologyGroup
800East96thStreet
Indianapolis,IN46240USA
http://www.informit.com
Theauthorsandpublisherhavetakencareinwritingandprintingthisbookbutmakenoexpressedorimpliedwarrantyofanykindand
assumenoresponsibilityforerrorsoromissions.Noliabilityisassumedforincidentalorconsequentialdamagesinconnectionwithor
arisingoutoftheuseoftheinformationorprogramscontainedherein.
Manyofthedesignationsusedbymanufacturersandsellerstodistinguishtheirproductsareclaimedastrademarks.Wherethose
designationsappearinthisbook,andthepublisherwasawareofatrademarkclaim,thedesignationshavebeenprintedwithinitial
capitallettersorinallcapitals.
2
PrintISBN-100134076958
PrintISBN-13978-0134076959
Fifthedition,firstprinting,April2015
ReleaseK.5.1.1
3
Dedication
ForAaron’ssons,WaldenandOtto
∼
ForAdam’sdaughters,AimeeandLeah
∼
ForNate’sniecesandnephews
4
Acknowledgments
Creatingthisbookrequiredtheeffortsofmanypeople.Wewanttothankthemfortheirhelp.Theircontributionshavemadethisa
betterbookthanwecouldhaveeverwrittenalone.
ThankstothestudentswhotooktheCocoaprogrammingcourseattheBigNerdRanch.Theyhelpedusworkthekinksoutofthe
exercisesandexplanationsthatappearhere.Theircuriosityinspiredustomakethebookmorecomprehensive,andtheirpatiencemadeit
possible.
Thankyoutoallthereadersofthefirstfoureditionswhomadesuchgreatsuggestionsonourforums(http://forums.bignerdranch.com/
).
Thankyoutoourtechnicalreviewers,JuanPabloClaude,ChrisMorris,NickTeissler,PouriaAlmassi,andJohnGallagher,whomade
greatadditionsandcaughtmanyofourmostegregiouserrors.
Finally,averybigthankyoutooursupportteaminwritingthisbook:LizHoladay,forcopy-editing;ChrisLoper,whoseexcellent
toolchainmadewritingthisbookthatmucheasier;andmostofallSusanLoper,whosecollaborationhelpeduswritethekindofbook
webelievethistechnologydeserves.
5