Mark / LaMarche | More iPhone 3 Development | E-Book | www.sack.de
E-Book

E-Book, Englisch, 552 Seiten

Mark / LaMarche More iPhone 3 Development

Tackling iPhone SDK 3
1. ed
ISBN: 978-1-4302-2506-5
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

Tackling iPhone SDK 3

E-Book, Englisch, 552 Seiten

ISBN: 978-1-4302-2506-5
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



Interested in iPhone development? Want to learn more? Whether you're a self-taught iPhone development genius or have just made your way through the pages of Beginning iPhone 3 Development, we have the perfect book for you. More iPhone 3 Development: Tackling iPhone SDK 3 digs deeper into Apple's latest SDK. Best-selling authors Dave Mark and Jeff LaMarche explain concepts as only they can, covering topics like Core Data, peer-to-peer networking using GameKit and network streams, working with data from the web, MapKit, in-application e-mail, and more. All the concepts and APIs are clearly presented with code snippets you can customize and use, as you like, in your own apps. If you are going to write a professional iPhone app, you'll want to get your arms around Core Data, and there's no better place to do so than in the pages of this book. The book continues right where Beginning iPhone 3 Development left off with a series of chapters devoted to Core Data, the standard for persistence that Apple introduced to iPhone with SDK 3. Jeff and Dave carefully step through each of the Core Data concepts and show you techniques and tips specifically for writing larger applications-offering a breadth of coverage you won't find anywhere else. The Core Data coverage alone is worth the price of admission. But there's so much more. This book covers a variety of networking mechanisms, from GameKit's relatively simple BlueTooth peer-to-peer model, to the addition of Bonjour discovery and network streams, through the complexity of accessing files via the web. Dave and Jeff will also take you through coverage of concurrent programming and some advanced techniques for debugging your applications. Whether you are a relative newcomer to iPhone development or an old hand looking to expand your horizons, there's something for everyone in More iPhone 3 Development. Note: A few of the apps in this book demonstrate technologies not yet supported by the simulator. To run them on your iPhone or iPod touch, you'll need to join one of Apple's paid iPhone developer programs.

Dave Mark is a longtime Mac developer and author who has written a number of books on Mac and iOS development, including Beginning iPhone 4 Development (Apress, 2010), More iPhone 3 Development (Apress, 2010), Learn C on the Mac (Apress, 2008), The Macintosh Programming Primer series (Addison-Wesley, 1992), and Ultimate Mac Programming (Wiley, 1995). Dave loves the water and spends as much time as possible on it, in it, or near it. He lives with his wife and three children in Virginia.

Mark / LaMarche More iPhone 3 Development jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Contents at a Glance;5
2;Table of contents ;6
3;About the Authors;13
4;About the Technical Reviewer;14
5;Acknowledgments;15
6;Preface;16
7;Chapter 1 Here We Go Round Again;17
7.1;What This Book Is;17
7.2;What You Need to Know;17
7.3;What You Need Before You Can Begin;18
7.4;What’s In this Book;20
7.5;Are You Ready?;22
8;Chapter 2 The Anatomy of Core Data;24
8.1;A Brief History of Core Data;25
8.2;Creating a Core Data Template Application;25
8.3;Core Data Concepts and Terminology;27
8.4;The Data Model and Persistent Store;28
8.4.1;The Data Model Class: NSManagedObjectModel;29
8.4.2;The Persistent Store and the Persistent Store Coordinator;31
8.4.3;Reviewing the Data Model;33
8.5;Entities and the Data Model Editor;33
8.5.1;Entities;33
8.5.2;Properties;34
8.5.2.1;Attributes;34
8.5.2.2;Relationships;35
8.5.2.3;Fetched Properties;36
8.5.2.4;Fetch Requests;36
8.6;Managed Objects;36
8.6.1;Key-Value Coding;36
8.6.2;Managed Object Context;37
8.6.3;Saves on Terminate;38
8.7;Loading Data from the Persistent Store;39
8.8;The Fetched Results Controller;41
8.8.1;Creating a Fetched Results Controller;41
8.8.2;The Fetched Results Controller Delegate Methods;44
8.8.2.1;Will Change Content Delegate Method;44
8.8.2.2;Did Change Content Delegate Method;45
8.8.2.3;Did Change Object Delegate Method;45
8.8.2.4;Did Change Section Delegate Method;50
8.8.3;Retrieving a Managed Object from the Fetched ResultsController;51
8.8.4;Creating and Inserting a New Managed Object;51
8.8.5;Deleting Managed Objects;53
8.9;Putting Everything in Context;54
9;Chapter 3 A Super Start: Adding, Displaying, and Deleting Data;56
9.1;Setting up the Xcode Project;57
9.1.1;Application Architecture;58
9.1.2;Modifying the Application Delegate Interface;59
9.1.3;Adding to the Application Delegate Implementation;60
9.2;Creating the Table View Controller;61
9.3;Setting up Main Window.xib;62
9.3.1;Connecting the Outlets;65
9.4;Designing the Data Model;65
9.4.1;Adding an Entity;66
9.4.2;Editing the New Entity;67
9.4.3;Adding Attributes to the New Entity;69
9.4.4;Adding the Name Attribute;69
9.4.5;Editing the Attribute;70
9.4.5.1;Attribute Types;71
9.4.5.2;The Integer Datatypes;71
9.4.5.2.1;The Decimal, Double, and Float Datatypes;72
9.4.5.2.2;The String Datatype;72
9.4.5.2.3;The Boolean Datatype;72
9.4.5.2.4;The Date Datatype;72
9.4.5.2.5;The Binary Datatype;72
9.4.5.2.6;The Transformable Datatype;73
9.4.5.3;Setting the Name Attributes’s Type;73
9.4.5.4;Adding the Rest of the Attributes;74
9.5;Creating Hero List View Controller;75
9.5.1;Declaring the Fetched Results Controller;75
9.5.2;Drag Two Icons to Your Project;78
9.5.3;Designing the Hero List View Controller Interface;79
9.5.4;Implementing the Hero View Controller;81
9.6;Let ‘Er Rip;94
9.7;Done, but Not Done;96
10;Chapter 4 The Devil in the Detail View;97
10.1;Table-Based vs. Nib-Based Detail Views;98
10.2;Detail Editing View Challenges;99
10.3;Controlling Table Structure with Arrays;101
10.4;Paired Arrays;101
10.4.1;Nested Arrays;102
10.4.2;Paired Nested Arrays;103
10.4.3;Representing Our Table Structure with Arrays;103
10.4.4;Nested Arrays, Categorically Speaking;104
10.4.5;Updating the SuperDB Project;104
10.5;Formatting of Attributes;106
10.6;Creating the Detail View Controller;108
10.6.1;Declaring Instance Variables and Properties;110
10.6.2;Implementing the Viewing Functionality;111
10.6.3;Using the New Controller;117
10.6.3.1;Declaring the Outlet;117
10.6.3.2;Adding the Instance to MainWindow.xib;118
10.6.3.3;Pushing the New Instance onto the Stack;119
10.6.4;Trying Out the View Functionality;120
10.7;Adding Editing Subcontrollers;121
10.7.1;Creating the Superclass;122
10.7.2;Creating the String Attribute Editor;126
10.7.3;Creating the Date Attribute Editor;129
10.7.4;Using the Attribute Editors;132
10.8;Implementing a Selection List;134
10.8.1;Creating the Generic Selection List Controller;134
10.9;Devil’s End;139
11;Chapter 5 Preparing for Change: Migrations and Versioning;140
11.1;About Data Models;141
11.1.1;Data Models Are Compiled;141
11.1.2;Data Models Can Have Multiple Versions;142
11.1.2.1;Creating a New Data Model Version;143
11.1.2.2;The Current Data Model Version;144
11.1.3;Data Model Version Identifiers;144
11.1.4;Using the Versioned Data Model;145
11.2;Migrations;146
11.2.1;Lightweight vs. Standard;147
11.2.2;Standard Migrations;147
11.2.3;Setting up Your App to Use Lightweight Migrations;147
11.3;Time to Migrate On;149
12;Chapter 6 Custom Managed Objects;150
12.1;Updating the Data Model;153
12.1.1;Adding the Age Attribute;154
12.1.2;Adding the Favorite Color Attribute;154
12.1.3;Adding a Minimum Length to the Name Attribute;155
12.2;Creating the Hero Class;156
12.3;Tweaking the Hero Header;158
12.4;Defaulting;159
12.5;Validation;160
12.5.1;Single-Attribute Validations;161
12.5.2;Multiple-Attribute Validations;163
12.6;Virtual Accessors;164
12.7;Adding Validation Feedback;165
12.7.1;Updating the Managed Object Attribute Editor Header File;165
12.7.2;Updating the Managed Object Attribute Editor Implementation File;166
12.7.3;Updating the Subclasses to Use Validation;167
12.7.3.1;Updating ManagedObjectStringEditor;167
12.7.3.2;Updating ManagedObjectDateEditor;168
12.7.3.3;Updating ManagedObjectSingleSelectionListEditor;168
12.8;Creating the Value Transformer;168
12.9;Creating the Color Attribute Editor;171
12.10;Displaying the New Attributes in Hero Edit Controller;174
12.11;The Display Problem;176
12.12;Adding View-Only Support to Hero Edit Controller;178
12.12.1;Hiding the Disclosure Indicator;178
12.12.2;Handling Taps on Read-Only Attributes;179
12.13;Color Us Gone;180
13;Chapter 7 Relationships, Fetched Properties, and Expressions;181
13.1;Expanding Our Application: Superpowers and Reports;182
13.2;Relationships;184
13.2.1;To-One Relationships;185
13.2.2;To-Many Relationships;186
13.2.3;Inverse Relationships;188
13.2.4;Delete Rules;189
13.3;Fetched Properties;190
13.4;Creating Relationships and Fetched Properties in the Data Model Editor;191
13.4.1;Adding the Power Entity;191
13.4.2;Creating the Powers Relationship;192
13.4.3;Creating the Inverse Relationship;193
13.4.4;Creating the olderHeroes Fetched Property;193
13.4.5;Creating the youngerHeroes Fetched Property;197
13.4.6;Creating the sameSexHeroes Fetched Property;198
13.4.7;Creating the oppositeSexHeroes Fetched Property;199
13.5;Adding Relationships and Fetched Properties to the Hero Class;201
13.6;The Big Refactor;202
13.6.1;Renaming the Class;203
13.6.2;Refactoring the hero Instance Variable;205
13.6.3;Removing the Arrays;205
13.6.4;Supporting Save and Cancel Buttons;205
13.6.4.1;Adding the isNew Method to NSManagedObject;207
13.6.4.2;Adding the Save and Cancel Buttons;208
13.6.5;Adding Support for To-Many Relationships;209
13.6.5.1;Turning on Edit Mode;209
13.6.5.2;Setting Row Indentation;209
13.6.5.3;Setting the Correct Number of Rows for To-Many Sections;211
13.6.5.4;The Set Problem;211
13.6.5.5;Specifying the Editing Style for the Rows;213
13.6.5.6;Displaying To-Many Sections;213
13.6.5.7;Updating Row Selection for To-Many Relationships;217
13.6.5.8;Handling To-Many Inserts and Deletes;221
13.7;Using the New Generic Controller;223
13.7.1;Adding Factory Methods for Hero and Power;223
13.7.2;Deleting the Nib Instance;227
13.7.3;Updating HeroListController;227
13.8;Creating the Fetched Property Attribute Controller;228
13.9;Cleaning Up Deleted Objects;230
13.10;Wonderful to the Core;233
14;Chapter 8 Peer-to-Peer Over Bluetooth Using GameKit;235
14.1;This Chapter’s Application;236
14.2;Network Communication Models;239
14.2.1;Client-Server Model;239
14.2.2;Peer-to-Peer Model;240
14.2.3;Hybrid Client-Server/Peer-to-Peer;241
14.3;The GameKit Session;242
14.3.1;Creating the Session;242
14.3.2;Finding and Connecting to Other Sessions;243
14.3.3;Listening for Other Sessions;244
14.3.4;Sending Data to a Peer;244
14.3.5;Packaging Up Information to Send;245
14.3.6;Receiving Data from a Peer;246
14.3.7;Closing Connections;247
14.4;The Peer Picker;247
14.4.1;Creating the Peer Picker;247
14.4.2;Handling a Peer Connection;248
14.4.3;Creating the Session;248
14.5;Creating the Project;249
14.5.1;Turning Off the Idle Timer;249
14.5.2;Importing the GameKit Framework;250
14.5.3;Designing the Interface;251
14.5.3.1;Setting Up the View Controller Header;252
14.5.3.2;Designing the Game Board;256
14.5.3.3;Creating the TicTacToePacket Object;258
14.5.3.4;Implementing the Tic-Tac-Toe View Controller;262
14.6;Trying It Out;278
14.7;Game On!;279
15;Chapter 9 Online Play: Bonjour and Network Streams;280
15.1;This Chapter’s Application;280
15.2;Overview of the Process;282
15.3;Setting Up a Listener;282
15.3.1;Callback Functions and Run Loop Integration;283
15.3.2;Configuring a Socket;284
15.3.2.1;Declaring a Socket Context;284
15.3.2.2;Creating a Socket;285
15.3.3;Specifying a Port for Listening;286
15.3.4;Registering the Socket with the Run Loop;289
15.3.5;Implementing the Socket Callback Function;289
15.3.6;Stopping the Listener;290
15.4;Bonjour;290
15.4.1;Creating a Service for Publication;291
15.4.1.1;Publishing a Bonjour Service;292
15.4.1.2;Stopping a Bonjour Service;293
15.4.1.3;Delegate Methods for Publication;293
15.4.2;Searching for Published Bonjour Services;294
15.4.3;Browser Delegate Methods;295
15.4.4;Resolving a Discovered Service;296
15.5;Streams;297
15.5.1;Opening a Stream;298
15.5.2;The Stream and Its Delegate;298
15.5.3;Receiving Data from a Stream;299
15.5.4;Sending Data Through the Stream;300
15.6;Putting It All Together;301
15.7;Updating Tic-Tac-Toe for Online Play;301
15.7.1;Adding the Packet Categories;302
15.7.2;Implementing the Online Session Object;304
15.7.3;Creating the Listener Object;315
15.7.4;Creating the Peer Browser;320
15.7.4.1;Creating the Peer Browser Files;320
15.7.4.2;Writing the Peer Browser Header;321
15.7.4.3;Building the Peer Browser Interface;321
15.7.4.4;Implementing the Peer Browser View Controller;322
15.7.5;Updating TicTacToeViewController to Support Online Play;327
15.8;Time to Play;337
16;Chapter 10 Working with Data from the Web;338
16.1;Setting Up the Application Skeleton;340
16.1.1;Declaring Actions and Outlets;340
16.1.2;Designing the Interface;342
16.1.3;Implementing the Stubs;344
16.2;Retrieving Data Using Foundation Objects;345
16.3;Retrieving Data Synchronously;348
16.3.1;The URL Request;348
16.4;Retrieving Data Asynchronously;353
16.4.1;NSURLConnection Delegate Methods;354
16.4.2;Adding Asynchronous Retrieval to WebWorks;355
16.5;Request Types and Form Parameters;359
16.5.1;Specifying the HTTP Request Types;359
16.5.2;Form Parameters;360
16.5.2.1;GET Parameters;361
16.5.2.2;POST Parameters;361
16.5.3;Building the RequestTypes Application;362
16.6;404 Conclusion Not Found;367
17;Chapter 11 MapKit;368
17.1;This Chapter’s Application;369
17.2;Overview and Terminology;370
17.3;The Map View;371
17.3.1;Map Types;371
17.3.2;User Location;373
17.3.3;Coordinate Regions;373
17.3.3.1;Converting Degrees to Distance;375
17.3.3.2;Accommodating Aspect Ratio;376
17.3.4;Setting the Region to Display;376
17.3.5;The Map View Delegate;376
17.3.5.1;Map Loading Delegate Methods;377
17.3.5.2;Region Change Delegate Methods;377
17.4;Annotations;378
17.4.1;The Annotation Object;379
17.4.2;The Annotation View;379
17.4.3;Adding and Removing Annotations;380
17.4.4;Selecting Annotations;381
17.4.5;Providing the Map View with Annotation Views;381
17.5;Reverse Geocoding;382
17.6;Building the MapMe Application;384
17.6.1;Declaring Outlets and Actions;384
17.6.2;Building the Interface;385
17.6.3;Writing the Annotation Object Class;387
17.6.4;Implementing MapMeViewController;390
17.6.5;Linking the Map Kit and Core Location Frameworks;398
17.7;Go East, Young Programmer;399
18;Chapter 12 Sending Mail;400
18.1;This Chapter’s Application;400
18.2;The MessageUI Framework;403
18.2.1;Creating the Mail Compose View Controller;403
18.2.2;Prepopulating the Subject Line;403
18.2.3;Prepopulating Recipients;403
18.2.4;Setting the Message Body;404
18.2.5;Adding Attachments;404
18.2.6;Presenting the Mail Compose View;404
18.2.7;The Mail Compose View Controller Delegate Method;404
18.3;Building the MailPic Application;405
18.3.1;Declaring Outlets and Actions;406
18.3.2;Building the User Interface;406
18.3.3;Implementing the View Controller;407
18.3.4;Linking the MessageUI Framework;412
18.4;Mailing It In…;412
19;Chapter 13 iPod Library Access;413
19.1;This Chapter’s Application;413
19.2;Working with the iPod Library;415
19.2.1;Media Items;416
19.2.1.1;Media Item Persistent ID;417
19.2.1.2;Media Type;417
19.2.1.3;Filterable String Properties;419
19.2.1.4;Nonfilterable Numeric Attributes;419
19.2.1.5;Retrieving Lyrics;420
19.2.1.6;Retrieving Album Artwork;421
19.2.1.7;Retrieving the Date Last Played;421
19.2.2;Media Item Collections;421
19.2.2.1;Creating a New Collection;421
19.2.2.2;Retrieving Media Items;421
19.2.2.3;Creating Derived Collections;422
19.2.3;Media Queries and Media Property Predicates;422
19.2.4;The Media Picker Controller;425
19.2.4.1;Handling Media Picker Cancels;426
19.2.4.2;Handling Media Picker Selections;426
19.2.5;The Music Player Controller;426
19.2.5.1;Creating the Music Player Controller;427
19.2.5.2;Determining If the Music Player Controller Is Playing;427
19.2.5.3;Specifying the Music Player Controller’s Queue;427
19.2.5.4;Getting or Setting the Currently Playing Media Item;428
19.2.5.5;Skipping Tracks;428
19.2.5.6;Seeking;429
19.2.5.7;Playback Time;429
19.2.5.8;Repeat and Shuffle Modes;429
19.2.5.9;Adjusting the Music Player Controller’s Volume;430
19.2.5.10;Music Player Controller Notifications;431
19.3;Building the Simple Player Application;432
19.3.1;Adding Media Item Collection Functionality;432
19.3.2;Declaring Outlets and Actions;436
19.3.3;Building the User Interface;438
19.3.4;Implementing the Simple Player View Controller;442
19.3.5;Taking Simple Player for a Spin;456
19.4;Avast! Rough Waters Ahead!;456
20;Chapter 14 Keeping Your Interface Responsive;458
20.1;Exploring the Concurrency Problem;460
20.2;Creating the Stalled Application;461
20.2.1;Declaring Actions and Outlets;461
20.2.2;Designing the Interface;461
20.2.3;Implementing the Stalled View Controller;462
20.3;Timers;465
20.3.1;Creating a Timer;465
20.3.2;Stopping a Timer;466
20.3.3;Limitations of Timers;466
20.4;Fixing Stalled with a Timer;467
20.4.1;Creating the Batch Object;467
20.4.2;Updating the Controller Header;469
20.4.3;Updating the Nib;470
20.4.4;Updating the View Controller Implementation;470
20.5;Operation Queues & Concurrency;475
20.5.1;Threads;476
20.5.1.1;Race Conditions;476
20.5.1.2;Mutex Locks and @synchronized;478
20.5.1.3;Atomicity and Thread Safety;479
20.5.1.4;Deadlocks;481
20.5.1.5;Sleepy Time;481
20.5.2;Operations;482
20.5.2.1;Operation Dependencies;483
20.5.2.2;Operation Priority;483
20.5.2.3;Other Operation State;484
20.5.2.4;Cancelling an Operation;485
20.5.3;Operation Queues;485
20.5.3.1;Adding Operations to the Queue;485
20.5.3.2;Setting the Maximum Concurrent Operation Count;485
20.5.3.3;Suspending the Queue;486
20.6;Fixing Stalled with an Operation Queue;486
20.6.1;Creating Square Root Application;487
20.6.2;Changes to Stalled View Controller.h;492
20.6.3;Adjusting the User Interface;493
20.7;Updating Stalled View Controller.m;494
20.8;Queue ’em Up;500
21;Chapter 15 Debugging;502
21.1;The Debugger;503
21.1.1;Breakpoints;504
21.1.1.1;The Debugger Editing Pane;507
21.1.1.2;The Stack Trace;508
21.1.1.3;The Variable List;509
21.1.1.4;The Debugging Controls;510
21.1.1.5;Trying Out the Debug Controls;511
21.1.1.6;The Breakpoint Window and Symbolic Breakpoints;515
21.1.1.7;Conditional Breakpoints;516
21.1.1.8;Breakpoint Actions;518
21.1.2;The GDB Console;520
21.1.2.1;The Info Command;520
21.1.2.2;Working with Breakpoints;520
21.1.2.2.1;Creating Breakpoints;521
21.1.2.2.2;Removing Breakpoints;521
21.1.2.3;Printing Data and Object Values;522
21.1.2.4;Calling Functions and Methods;522
21.2;Static Analysis;523
21.3;Specific Bugs;524
21.3.1;Overreleasing Memory;524
21.3.1.1;NSZombie;528
21.3.2;Infinite Recursion;530
21.3.3;Missed Outlet and Action Connections;532
21.4;GDB: Stopped at Concluding Paragraph;532
22;Chapter 16 The Road Goes Ever On…;534
22.1;Getting Unstuck;534
22.1.1;Apple’s Documentation;535
22.1.2;Mailing Lists;535
22.1.3;Discussion Forums;535
22.1.4;Web Sites;536
22.1.5;Blogs;536
22.1.6;And If All Else Fails…;537
22.2;Farewell;537
23;Index;538



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.