ebook img

iPhone SDK 3 Programming: Advanced Mobile Development for Apple iPhone and iPod touch (Wiley) PDF

672 Pages·2009·0.2 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview iPhone SDK 3 Programming: Advanced Mobile Development for Apple iPhone and iPod touch (Wiley)

iPhone SDK 3 Programming Advanced Mobile Development for Apple iPhone and iPod touch MaherAli,PhD BellLabs,Alcatel-Lucent A John Wiley and Sons, Ltd, Publication iPhone SDK 3 Programming iPhone SDK 3 Programming Advanced Mobile Development for Apple iPhone and iPod touch MaherAli,PhD BellLabs,Alcatel-Lucent A John Wiley and Sons, Ltd, Publication Thiseditionfirstpublished2009 ©2009,JohnWiley&Sons,Ltd Registeredoffice JohnWiley&SonsLtd,TheAtrium,SouthernGate,Chichester,WestSussex,PO198SQ,United Kingdom. Fordetailsofourglobaleditorialoffices,forcustomerservicesandforinformationabouthowto applyforpermissiontoreusethecopyrightmaterialinthisbookpleaseseeourwebsiteat www.wiley.com. Therightoftheauthortobeidentifiedastheauthorofthisworkhasbeenassertedinaccordance withtheCopyright,DesignsandPatentsAct1988. AllRightsReserved.Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,or transmitted,inanyformorbyanymeans,electronic,mechanical,photocopying,recordingor otherwise,exceptaspermittedbytheUKCopyright,DesignsandPatentsAct1988,withoutthe priorpermissionofthepublisher. Wileyalsopublishesitsbooksinavarietyofelectronicformats.Somecontentthatappearsinprint maynotbeavailableinelectronicbooks. Designationsusedbycompaniestodistinguishtheirproductsareoftenclaimedastrademarks.All brandnamesandproductnamesusedinthisbookaretradenames,servicemarks,trademarksor registeredtrademarksoftheirrespectiveowners.Thepublisherisnotassociatedwithanyproduct orvendormentionedinthisbook.Thispublicationisdesignedtoprovideaccurateandauthoritative informationinregardtothesubjectmattercovered.Itissoldontheunderstandingthatthe publisherisnotengagedinrenderingprofessionalservices.Ifprofessionaladviceorotherexpert assistanceisrequired,theservicesofacompetentprofessionalshouldbesought. Trademarks:WileyandtheWileyPublishinglogoaretrademarksorregisteredtrademarksofJohn WileyandSons,Inc.and/oritsaffiliatesintheUnitedStatesand/orothercountries,andmaynotbe usedwithoutwrittenpermission.iPhoneandiPodaretrademarksofAppleComputer,Inc.Allother trademarksarethepropertyoftheirrespectiveowners.WileyPublishing,Inc.isnotassociatedwith anyproductorvendormentionedinthebook.ThisbookisnotendorsedbyAppleComputer,Inc. ISBN978-0-470-68398-9 TypesetbySunriseSettingLtd,Torquay,UK. PrintedintheUnitedStatesofAmerica. CONTENTS Preface xv 1 GettingStarted 1 1.1 SDKandIDEBasics 1 1.1.1 ObtainingandinstallingtheSDK 1 1.1.2 Creatingaproject 2 1.1.3 FamiliarizingyourselfwiththeIDE 3 1.1.4 Lookingcloselyatthegeneratedcode 5 1.2 CreatingInterfaces 6 1.2.1 InterfaceBuilder 7 1.3 UsingtheDebugger 14 1.4 GettingMoreInformation 15 1.5 Summary 16 Problems 17 2 Objective-CandCocoa 19 2.1 Classes 20 2.1.1 Classdeclaration 20 2.1.2 HowdoIuseotherdeclarations? 21 2.1.3 Classdefinition 22 2.1.4 Methodinvocationanddefinition 22 2.1.5 Importanttypes 23 2.1.6 ImportantCocoaclasses 24 2.2 MemoryManagement 24 2.2.1 Creatinganddeallocatingobjects 24 2.2.2 Preventingmemoryleaks 25 2.3 Protocols 27 2.3.1 Protocolconformance 28 2.4 Properties 29 2.4.1 Propertydeclaration 29 2.4.2 Circularreferences 34 2.5 Categories 36 2.6 Posing 38 vi Contents 2.7 ExceptionsandErrors 38 2.7.1 Exceptions 38 2.7.2 Errors 43 2.8 Key-valuecoding(KVC) 45 2.8.1 AnexampleillustratingKVC 46 2.9 Multithreading 51 2.10 Notifications 55 2.11 TheObjective-CRuntime 56 2.11.1 Requiredheaderfiles 57 2.11.2 TheNSObjectclass 58 2.11.3 Objective-Cmethods 59 2.11.4 Examples 62 2.12 Summary 79 Problems 79 3 Collections 83 3.1 Arrays 83 3.1.1 Immutablecopy 86 3.1.2 Mutablecopy 88 3.1.3 Deepcopy 89 3.1.4 Sortinganarray 93 3.2 Sets 96 3.2.1 Immutablesets 97 3.2.2 Mutablesets 99 3.2.3 Additionalimportantmethods 100 3.3 Dictionaries 101 3.3.1 Additionalimportantmethods 103 3.4 Summary 103 Problems 104 4 AnatomyofaniPhoneApplication 105 4.1 HelloWorldApplication 105 4.1.1 Createamain.mfile 105 4.1.2 Createtheapplicationdelegateclass 106 4.1.3 Createtheuserinterfacesubclasses 107 4.2 BuildingtheHelloWorldApplication 108 4.3 Summary 113 Problems 113 5 TheView 115 5.1 ViewGeometry 115 5.1.1 Usefulgeometrictypedefinitions 115 5.1.2 TheUIScreenclass 117 5.1.3 Theframeandcenterproperties 118 Contents vii 5.1.4 Theboundsproperty 119 5.2 TheViewHierarchy 121 5.3 TheMultitouchInterface 121 5.3.1 TheUITouchclass 122 5.3.2 TheUIEventclass 123 5.3.3 TheUIResponderclass 123 5.3.4 Handlingaswipe 128 5.3.5 Moreadvancedgesturerecognition 132 5.4 Animation 137 5.4.1 UsingtheUIViewclassanimationsupport 137 5.4.2 Slidingview 141 5.4.3 Flipanimation 142 5.4.4 Transitionanimation 142 5.5 Drawing 145 5.6 Summary 147 Problems 147 6 Controls 149 6.1 TheFoundationofallControls 149 6.1.1 UIControlattributes 149 6.1.2 Target-actionmechanism 150 6.2 TheTextField 153 6.2.1 Interactingwiththekeyboard 155 6.2.2 Thedelegate 158 6.2.3 CreatingandworkingwithaUITextField 159 6.3 Sliders 160 6.4 Switches 161 6.5 Buttons 163 6.6 SegmentedControls 164 6.7 PageControls 167 6.8 DatePickers 168 6.9 Summary 170 Problems 170 7 ViewControllers 171 7.1 TheSimplestViewController 171 7.1.1 Theviewcontroller 171 7.1.2 Theview 173 7.1.3 Theapplicationdelegate 174 7.1.4 Summary:creatingasimpleMVCapplication 175 7.2 RadioInterfaces 177 7.2.1 Adetailedexample 177 7.2.2 Somecommentsontabbarcontrollers 182 7.3 NavigationControllers 186 viii Contents 7.3.1 Adetailedexample 187 7.3.2 Customization 193 7.4 ModalViewControllers 197 7.4.1 Adetailedexample 197 7.5 Summary 203 Problems 203 8 Special-PurposeViews 205 8.1 PickerView 205 8.1.1 Thedelegate 206 8.1.2 Anexample 207 8.2 ProgressViews 211 8.2.1 Anexample 213 8.3 ScrollView 215 8.4 TextView 217 8.4.1 Thedelegate 218 8.4.2 Anexample 218 8.5 AlertView 221 8.6 ActionSheet 224 8.7 WebView 225 8.7.1 Asimplewebviewapplication 226 8.7.2 Viewinglocalfiles 230 8.7.3 EvaluatingJavaScript 235 8.7.4 Thewebviewdelegate 242 8.8 Summary 247 Problems 247 9 TableView 249 9.1 Overview 249 9.2 TheSimplestTableViewApplication 250 9.3 ATableViewwithbothImagesandText 255 9.4 ATableViewwithSectionHeadersandFooters 257 9.5 ATableViewwiththeAbilitytoDeleteRows 258 9.6 ATableViewwiththeAbilitytoInsertRows 265 9.7 ReorderingTableRows 270 9.8 PresentingHierarchicalInformation 275 9.8.1 Detailedexample 278 9.9 GroupedTableViews 285 9.10 IndexedTableViews 288 9.11 DynamicTableViews 294 9.12 WhiteningTextinCustomCells 297 9.13 Summary 302 Problems 303 Contents ix 10 FileManagement 305 10.1 TheHomeDirectory 305 10.2 EnumeratingaDirectory 306 10.3 CreatingandDeletingaDirectory 308 10.4 CreatingFiles 309 10.5 RetrievingandChangingAttributes 312 10.5.1 Retrievingattributes 314 10.5.2 Changingattributes 315 10.6 WorkingwithResourcesandLow-levelFileAccess 317 10.7 Summary 320 Problems 321 11 WorkingwithDatabases 323 11.1 BasicDatabaseOperations 323 11.1.1 Opening,creating,andclosingdatabases 325 11.1.2 Tableoperations 325 11.2 ProcessingRowResults 327 11.3 PreparedStatements 330 11.3.1 Preparation 330 11.3.2 Execution 331 11.3.3 Finalization 331 11.3.4 Puttingittogether 331 11.4 User-definedFunctions 333 11.5 StoringBLOBs 337 11.6 RetrievingBLOBs 341 11.7 Summary 343 Problems 343 12 XMLProcessing 345 12.1 XMLandRSS 345 12.1.1 XML 345 12.1.2 RSS 347 12.1.3 ConfiguringtheXCodeproject 350 12.2 DocumentObjectModel(DOM) 351 12.3 SimpleAPIforXML(SAX) 358 12.4 AnRSSReaderApplication 367 12.5 PuttingItTogether 369 12.6 Summary 371 Problems 371 13 LocationAwareness 373 13.1 TheCoreLocationFramework 373 13.1.1 TheCLLocationclass 375 13.2 ASimpleLocation-awareApplication 377

Description:
I bought this book because I was struggling with some detail with navigation controllers. The book seemed to have the answer. Sadly the first example I looked at is flawed. In chapter 9, page 278 is the code line self.navigationItem.backBarButtonItem.title = @"Shows"; This is an attempt to give a ti
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.