Index

A

abstract classes

about, 67

NSNumber, 182

UIDocument, 287–288, 294–297, 299, 300–305, 310, 342

acceleration pop-up view, 471–474, 486–489

accelerometer, 490, 492–496

accessibility support, 532

accessor methods

custom Core Data, 381–383

managed object, 379–380

properties creating, 79, 81

setting WeightHistory defaults with, 155

accuracy of location data, 502–503

actions

adding method stub for, 176

connecting events and, 38–39

implementing, 177

saveWeight, 185

addChildViewController: subclass, 453, 454

alert views, 507

animation

adding, 460–462

calculating rotations of, 462–463

fade and bounce, 465–469

starting, 463–464

anti-aliasing graphics, 250

application sandbox

about, 272

exploring contents of, 282

including containers in, 324

SQLite database URL for local, 403–404

apps. See also converting app to Core Data; polishing apps; and specific apps

adding Settings to, 284, 355–359

application proxy, 473

application sandbox, 272, 282, 324, 403–404

data conflicts when saving, 311–314, 319

designing gestures on, 185

developing with iOS, 4–5

document type setup for, 292–294

entitlements for, 291–292

file handling by iOS, 272

iCloud support in, 291–297, 299–305

including and reading resource files in, 278

launch images for, 525–526

managing user preferences, 283–284

opening and closing, 130–131

productivity, 120–122

saving data to iCloud, 285–289

saving state of, 290–291

selecting location for, 9

sending to background and saving, 352

single tab bar in, 122

state flag disabling user from editing, 342, 346–347

syncing defaults in iCloud, 352–355

utility, 120

when to load and save, 306–307

ARC (Automatic Reference Counting), 91–98

about, 91

documentation for, 117

finding and preventing memory cycles, 92–95

garbage collection vs., 92

guidelines for, 95–96

managing Objective-C objects with classes, 53

memory management for Core Foundation data types, 96–98

retain attributes inoperable with, 80

selecting, 9

toll-free bridging with, 96–97

using blocks with, 116

architecture

building Health Beat model classes, 141–157

Core Data managed object model, 370–378

created by Tabbed Application template, 123, 124

linking model to controller, 158–163

arguments

about function, 59

hidden method, 74

passing values in functions, 61–63

separating, 73

arrays

about, 50–51

collection classes vs., 51

immutable, 152

loading and saving with keyed archiver, 295–299

mutable, 159–160

NSMutableArray and NSArray collection classes, 151

asserts, 253–255

Assets Library framework, 506–510

@dynamic directive, 82

@interface block, 73, 86

@optional keyword, 85

@property declaration, 81

@required keyword, 85

@synthesize directive, 81, 82

@implementation block, 73, 87

attributes

changing readwrite/readonly, 88

common property, 80

Core Data, 371

indexed, transient, and optional Core Data, 372

setting graph view, 238–239

setting managed object model date, 408–409

Automatic Reference Counting. See ARC

autorelease block, 13

autorotating views, 170–172

autosizing views, 170–172

awakeFromNib method, 241

B

background

remaining static in dynamic view, 442–443

resolving conflicts with URL in, 311–312

saving apps after sending to, 352

transitioning apps into, 306

Background attribute, 30

backing up files, 274–275

binary operators, 57

blocks, 112–116

about, 112–113

Apple’s documentation for, 117

declaring block variables, 113

passing index to, 215–216

bounce animation, 466–469

buttons

background colors for, 190

control states for, 178–179

creating custom, 176

modifying Core Animation layer for, 198–202

C

C language

abstract classes, 67

allocating memory for data structure in, 96

Carbon written in, 51

class inheritance in, 65–67

data structures, 49–53

data types, 46–48

enumerations in, 54–56

functions in, 58–63

Objective-C as superset of, 44

objects, 64–70

operators in, 56–58

order of operator precedence, 57–58

CAGradientLayer, 200–201

CALayer, 200–202, 205

callback blocks, 503–506

canvas

adding line segments on, 443–450

modifying with gesture recognizers, 481–489

resetting with shake, 456–457

view controller setting up, 455–457

Canvas class, 442–450

canvasViewController class, 455–457

categories, 86–87, 88

cells

about, 210

connecting table to/from prototype, 136–137

customizing table view history, 206–210

designing for static displays, 221–227

reusing, 139, 210

CGContextRestoreGState(), 248

CGContextStateGState(), 248

child view controllers, 453, 454, 456, 460

classes. See also abstract classes; and specific classes

calling methods for, 74

categories for adding methods to, 86–87

collection, 51, 151

convenience methods for, 78–79

defining object, 69–70

hierarchy of UIView, 66–67

iCloud-compatible protocols for, 287

inheritance of, 65–67

managing Objective-C objects with, 53

objects vs., 64

prefixes for, 8

using delegate with, 101

closing apps, 130–131

_cmd argument, 74

Cocoa framework, 44, 51

Cocoa Touch framework

Objective-C language in, 44

use of enumerations in, 56

using with Carbon and Cocoa, 51

view object inheritance in, 66

collection classes, 51, 151

color

assigning for progress bar, 471–473

button’s background, 190

pause view background, 459

comments, 59

comparisons in predicates, 386

conflicts

merging, 305, 308–320

resolving when saving data, 311–314, 319

connections

adding relationship to view controller, 135

configuring outlet, 32–33

deleting to HWMainViewController delegate outlet, 28

drawing between actions and events, 38–39

making gesture recognizer, 184

constants, 55

containers

accessing files in iCloud, 287

sharing among apps, 285

syncing data in local and iCloud, 289

view controllers for, 452, 453–455

controls. See designing controls

convenience methods, 78–79

converting app to Core Data, 400–437

adding Core Data to app, 400

building managed object model, 408–416

creating UIManagedDocument, 395–396, 400–406, 418

duplicate handle errors and fetch requests, 436

generating custom WeightEntry object, 410–416

modifying HistoryViewController, 419–432

populating graph with data from Core Data, 432–437

registering explicit saves for undo actions, 416

replacing weight history with document references, 417–418

setting managed object model attributes, 408–409

updating EnterWeightViewController, 416–419

coordinate systems

about, 252

calculating weight trend lines with, 255–256

changing cursor velocity using, 494–496

flipping and translating, 449–450

setting data coordinates, 260–263

using for gravity signals, 493–494, 495

Core Animation, 465–468

about, 198

controlling view transitions with, 465–469

modifying button layer using, 198–202

performance issues with, 204–205

supporting drawing for Retina display, 252, 253

unneeded to support GravityScribbler cursor, 452

Core Data, 368–399. See also converting app to Core Data

about, 282, 368

adding to Health Beat, 400

attributes, 371

custom accessors for, 381–383

features of, 369

fetch requests, 385–388

handing contexts to object, 379

instantiating managed objects, 379–385

limitations of iCloud on, 396

managed object context, 378–389

managed object model of, 370–378

migrating data to, 375–377

optimizing performance for, 396–400

persistent store coordinator, 389–392

properties, 370–375

replacing model layer with, 367

using UIManagedDocument subclass with, 395–396, 418

Core Foundation, 96–98

Core Graphics, 449–450

Core Image, 516–520

Core Location, 499–501, 509–510

Core Motion, 490–498

country settings, 147, 180

currency, 142

cursor

handling GravityScribbler, 446–449, 450–452

modifying velocity of, 494–496

updating position of, 448

user control of, 490–498

D

dangling pointers, 63

data

accessing with Core Motion, 490–491

defining structure of Core Data, 370

merging conflicting versions of, 305, 308–320

performance of large data objects, 398–399

saving to iCloud, 285–289

when to load and save app, 306–307

data migration, 375–377

data sources

connecting unit picker to, 191

delegates vs., 103–104

support for NSPredicate, 388

data structures, 49–53

arrays, 50–51

declaring pointers, 49

structs, 51–53

data types

float, 47–48

integer, 46–47, 48

memory management for Core Foundation, 96–98

setting size of, 47

dates

finding earliest and latest weight, 236–237

formatting and displaying current, 177, 180

handling attributes with Core Data, 371

declarations, 49

defaults

changing history view unit, 211–217

creating for weight unit, 154, 348–349

defining graph view, 242

setting with accessor methods, 155

storing user, 348–352

syncing across iCloud, 352–355

updating UI when changing, 350

delegates, 101–104

connecting unit picker to, 191

data sources vs., 103–104

defined, 21, 101

deleting connection to outlets, 28

formats for, 197

methods for, 102–103

protocol methods for, 103

using with classes, 101

designing controls, 439–521. See also exporting images; responding to user input

creating custom interfaces, 441

creating pop-up views, 457–460

custom UIViewController container, 452–457

customizing UIKit controls, 470–477

drawing line segments, 443–450

handling GravityScribbler cursor, 446–449, 450–452

helping user find controls, 185

limitations of UIControl, 478

managing pop-up views, 460–470

placing controls, 31

resizable and tiled images, 474–477

separating dynamic and static views, 442–450

UIAppearance proxy, 471–474

UIControl subclasses, 479–480

Detail Disclosure accessory, using, 207

DetailViewController class

connecting, 136

importing into HistoryViewController, 162–163

modifying for Core Data, 431–432

modifying header and implementation of, 161–162

devices. See iOS devices

direction of swipe, 484–486

directories. See also paths

calculating URL for Document, 323–324

copied during updates, 275

generating paths to, 272–273, 276–277

iOS management of, 274–275

manipulating paths to, 279–282

disabling

accelerometer updates, 496

idle timer, 441

location updates, 503–506

distribution profiles, 535, 536

documents

confirming iCloud storage of, 404

icons for, 293

loading iCloud, 320–341

monitoring state changes in, 308–309

moving into iCloud storage, 325

passing to subview controller, 405–406

saveless model for, 287, 300

saving and loading, 295–297, 299

sharing, 533–534

storing in iCloud, 286–288

tracking changes in, 300–305

unable to save state of, 342–343, 346

Done button, 20, 201–203

dot notation, 82, 83

drawing

grid in rounded rectangle, 248–251

line segments for Canvas class, 443–450

working with opaque view, 244, 245

drawRect: method, 243–244

E

editing

header file next to storyboard, 32

history view, 218–220

state disabling, 342, 346–347

storyboards, 15–21

email attachments, 511–517

encapsulating objects, 64–65

EnterWeightView, 168–169, 170–172

EnterWeightViewController

adding weightHistory property to, 161

creating and saving, 133

implementing actions in, 177

outlets for, 173–174

passing in modal view, 195–198

updating for Core Data, 416–419

entities

adding, 408

deleting Core Data, 373

inheritance for, 374–375

relationships defining connections with, 372–373

entitlements file, 286, 291–292

enumerations, 54–56

errors. See also testing

arrays as source of, 51

checking Core Data conversion for, 426

dangling pointers, 63

finding, 126–128

memory, 89–90

pointers as source of, 49

saving document state changes, 342–343

treating warnings as, 128

events. See also touch-based events

connecting actions and, 38–39

motion, 360–363, 490

triggering undo, 360–363

explorePath: method, 282

exporting images, 499–520

attaching to email, 511–517

saving to photo library, 499–510

sending with MMS messages, 511

using Twitter API to, 516–520

exporting UTI, 293–294

expressions, 57–58

extensions, 88, 410–411

F

faulting, 390–392, 397

fetch requests

accessing managed objects with, 385–389

converting graph data for Core Data, 432–437

creating, 377

duplicating, 436

optimizing, 397

round trips to persistent stores, 388

fetched results controller

accessing table objects with, 421–423

batch size for, 424

changing result content, 426–430

function of, 420

instantiating and assigning view controller to, 425–426

modifying history view controller to use, 419

notifications of changes by, 428–429, 430

files. See also .h files; .m files

auto-selecting companion, 33

backing up, 274–275

copied during updates, 275

entitlements, 286, 291–292

iCloud document storage for, 286–287

including and reading in apps, 278

manipulating directory paths, 279–282

.nib and .xib, 15

queries for iCloud, 328–334

scanning with jump bar, 35

sharing, 274, 533–534

first responder, 16–17

flipped-coordinate systems, 449–450

flipside view

changing text when user dismisses, 35–36

Hello World, 10, 40

passing text from main view label to, 36–37

flipside view controllers, 20, 29

float data types, 47–48, 144–146

formatting

current date, 177, 180

decimals, 147

universal number, 147, 180

Foundation framework, 96–97

frameworks. See also Cocoa Touch framework; Core Data

about, 5

Assets Library, 506–510

Cocoa, 44, 51

Foundation, 96–97

QuartzCore, 198

using class prefixes for, 8

functions, 58–63

G

genstrings utility, 532

geotagging images, 499–506

asking permission for, 500, 501, 502

Core Location support for, 499–501

generating location metadata, 508–510

getting location for, 501–506

updating location, 501–502

gesture recognizers, 183–185, 481–489

gestures. See also motion events

communicating availability of, 185

controlling cursor, 490–498

direction of swipe, 484–486

pan, 486–489

pause, 482–483

resetting canvas with shake, 456–457

swipe vs. pan, 481

tap, 481, 482–483

three-finger swipe, 483–486

triggering undo commands with shake, 360–363

git repository, 9, 165

Grand Central Dispatch (GCD), 445–446

graph views, 238–263

calculating weight coordinates, 262–263

defining default values for, 242

developing for Retina display, 252–253

drawing subpixel lines, 250

full trend lines in, 257–260

including reference lines and labels, 260–261

recreating graphics context when redrawn, 248

rotating, 267–268

setting properties and attributes, 238–239

single-entry trend lines, 253–256

updating weight changes in, 264–266

GraphStats class, 232–237

GraphViewController, 161, 432–437

gravity signals, 493–494, 495

GravityScribbler

about, 440

acceleration pop-up for, 471–474, 486–487

adding motion results for, 491–498

changing orientation of, 496–498

Core Location features used in, 501

creating gesture recognizers, 482–489

custom background images for, 474–477

customizing interface for, 441

displaying pop-up views, 457–460

flipping and translating coordinate systems, 449–450

gestures used in, 482

handling cursor for, 446–449, 450–452

resetting canvas, 456–457

syncing reads and writes with GCD, 444–446

GUI (graphical user interface). See user interface

H

.h (header) files

avoiding #import directives in, 150

declaring class interface in, 69–70

editing next to storyboard, 32

protocol declarations in, 85

updating Core Data view controller, 416

using precompiled prefix, 12

viewing Hello World, 11, 21

Health Beat. See also converting app to Core Data; graph views

adding and removing weights in, 155–157

building GraphStats for, 232–237

changing weight units, 189–203

committing changes to git repository, 165

configuring tab bar, 133–140

connecting history and detail views, 162–163

converting to Core Data framework, 400

custom button in, 176

customizing table view history cells for, 206–210

deleting unneeded elements from, 124–125

displaying keyboard, 172

document type setup for, 292–294

drawing connections to/from cells, 136–137

drawing grid in rounded rectangle, 248–251

editing history view, 218–220

embedding view in navigation controller, 136

enabling static analyzer for, 126–128

enter weight view, 168

EnterWeightView outlets and actions, 173–174

entitlements for, 291–292

filtering keyboard input, 186–188

formatting decimals in, 147

iCloud support for, 291–297, 299–305

icons for, 524–525

linking model to controller, 158–163

merging conflicting data versions, 305, 308–320

moving files to iCloud, 320, 321

QuartzCore framework added to, 198

recognizing swipe gesture, 183–185

removing repetitive code in, 149

rounded corners for views, 198–203

running skeletal interface for, 140

saving user defaults, 348–359

selecting supported device orientation, 125

settings and preferences for, 355–359

Settings view, 357

showing detail in static tables, 221–227

starting project for, 123–124

storyboard, 137, 138

tab images for, 128

tasks of, 122

undoing changes in, 300–305

updating history view, 211–217

using pounds and kilograms in, 142–149

WeightEntry class for, 141–150

WeightHistory class, 150–157

Hello World

attributes for segues, 20

autorelease block in, 13

building and launching in simulator, 10

creating workspace for, 8–10

declaring window property, 22

Done button connections for, 20

examining main view controller for, 18, 19

flipside view controller for, 20

how objects are created in, 21

main and flipside views of, 10, 40

modifying main view, 30–31

object graph of, 29

outlet for, 32–34

refining interface, 36–40

text field, 35–36

UIApplicationMain() arguments in, 13–14

viewing Navigator area for, 11

Hello World-Info.plist file, 12

hidden method arguments, 74

hiding pop-up views, 469–470

hierarchies

saving object, 296

UIView class, 66–67

view, 442–450, 452–453, 479–480

HistoryCell, 206–210

HistoryViewController class

adding weightHistory property to, 161

converting to Core Data, 419–432

embedding in navigation controller, 136

importing DetailViewController class into, 162–163

updating details in, 211–217

HWAppDelegate class, 21

HWAppDelegate.m file, 11, 22–24

HWMainViewController.m file

changing label text when flipside view dismissed, 35–36

deleting connection to delegate outlet, 28

examining, 18, 19

object graph of, 29

setting property to nil value, 34

I

ibtool utility, 531

iCloud, 285–289. See also UIDocument abstract class

about, 285–286

accessing files in, 287

document loading for, 320–341

key-value storage for, 289

merging conflicting versions, 305, 308–320

moving documents into, 325

opening documents in, 321

preparing Health Beat to support, 291–297, 299–305

queries searching for files in, 328–334

setting URLs for, 323–324, 401–404

storing documents in, 286–288

support for persistent store, 394–395

using key-value storage to sync defaults, 352–355

using UIDocument abstract class, 287–288

icons

adding, 524–525, 526

document, 293

identifiers

allowing reuse of cells, 210

checking segue, 26–27

reusing, 139

Identity inspector, 18, 19

images. See also exporting images; icons

adding line segments to Canvas, 443–450

adding tab button, 128

attaching to email, 511–517

designating launch screen, 526

geotagging, 499–506

including in MMS messages, 511

launch, 525–526

low- and high-resolution, 474

providing iTunes artwork, 527

resetting canvas with shake, 456–457

resizable and tiled, 474–477

setting for pause view, 459

solving flipped, 449–450

implementation files. See .m files

#import directives

avoiding in header files, 150

updating HistoryViewController, 419

incoming arrow, 18

InfoPlist.strings file, 12

inheritance

browsing inherited methods and properties, 67

C’s class, 65–67

entity, 374–375

Objective-C methods for, 83–84

init (initializer) methods, 75–78

consistent naming of, 75

designated for class and superclass, 75–76

general tips for, 83

instantiating objects with, 68

loading custom object in nibs, 164

modifying code snippet for, 76–77

setting instance variables in default, 78

using for WeightEntry objects, 142–143

instance methods, 148

instance variables, 78, 81

instantiating objects

initializer methods used for, 75–78

managed objects, 413–415

two-step process for, 68–69

Instruments

detecting views using offscreen rendering, 204, 205

searching for retain cycles with, 94–95

troubleshooting Core Data with, 399

integer data types, 46–47, 48

inverse relationships, 372–373

iOS. See also iCloud

about, 272

accessibility support, 532

C data types for, 48

coordinate system in Mac OS and, 449–450

copy-paste system in, 228

Core Animation performance issues, 204–205

developing apps with, 4–5

displaying textual output in, 227–228

generating directory paths in, 272–273, 276–277

handing contexts object to object, 379

managing user preferences, 283–284

memory management for, 89–90

nested contexts, 378–379

nib loading in Mac OS and, 164

SDK version used in projects, 6

specifying deployment target for, 528–530

UIKeyboardTypeDecimalPad keyboard type, 170

using UIAppearance proxy, 471–474

when to load and save apps, 306–307

iOS Developer Program, 6, 129

iOS devices. See also gestures; orientation

checking data migration between, 407

content and container view controllers for, 452

launch screen orientation for, 526

motion support on, 490

running and testing, 129

running skeletal Health Beat interface, 140

sharing data from iCloud, 285–286

syncing defaults across, 352–355

testing drawing code on, 253

tracking location of, 499–501

universal number formatting for, 147, 180

iOS SDK

application task methods in, 130–132

build setting for latest, 528

gaining full access to, 129

version used in projects, 6

iPad

content and container view controllers for, 452

device motion support for, 490

launch screens supported, 526

iPhone

building simulator for, 10

content and container view controllers for, 452

device motion support for, 490

Human Interface Guidelines for apps, 120

launch screens supported, 526

Retina display of, 252–253

iPod touch, 490

isCloudAvailable, 325, 327

iTunes, 274

iTunes App Store

about, 4

artwork for, 527

providing app requirements for, 527–528

submitting final app to, 536–537

J

jump bar, 35, 153

K

key paths

KVC methods using, 106

KVO and, 107–108, 154

key-value storage, 289, 291, 292

keyboard

displaying, 182–183

filtering input from, 186–188

types of, 170

keyed archives, 298

KVC (key-value coding), 106–107

KVO (key-value observing)

about, 107–108

Apple’s documentation for, 117

monitoring changes in property values with, 154, 155–157

posting manual notifications vs., 155–157, 212–215

registering/unregistering notifications, 339

L

labels

adding to class details in jump bar, 153

adding to enter weight view, 168–169

aligning and centering, 31

autosizing, 172

changing text when flipside view dismissed, 35–36

customizing history cell, 207–208

runtime changes to text, 32

layers

modifying button’s Core Animation, 198–202

replacing model, 367, 368

separating dynamic and static elements in, 442–450, 452, 479–480

Leaks profile (Instruments), 95

libraries

class prefixes for, 8

displaying Object, 30

saving images to photo, 499–510

loading

arrays with keyed archiver, 295–299

document data automatically, 287–288

iCloud documents, 320–341

knowing time for app, 306–307

minimizing number of objects, 298

localizing apps, 530–532

location

desired accuracy of, 502–503

disabling updates for, 503–506

generating metadata for image geotags, 508–510

including in tweets, 517

privacy issues and tracking, 499

updating, 501–502

locking control in view, 171

low memory warnings, 132

M

.m (implementation) files

implementing object classes, 69, 70

implementing WeightEntry managed objects, 412–413

updating Core Data view controller, 416

using functions in, 59

viewing Hello World, 11, 22–24

Mac OS

downloading Xcode, 129

iOS coordinate system vs., 449–450

loading of nibs in iOS and, 164

magnetometer, 490, 500

main view controllers

changing label when flipside view dismissed, 35–36

Hello World, 18, 19, 34

object graph of Hello World, 29

main view in Hello World, 10, 40

MainStoryBoard.storyboard file, 11

managed object context, 378–389

faulting objects, 390–392

fetch requests for managed objects, 385–388

function of, 378

instantiating managed objects, 379–385

relation to persistent store coordinator, 389

working with child, 415

managed object model, 370–378

creating Health Beat, 408–416

defining entities, 370–375

fetch requests and configurations, 377–378

instantiating managed objects, 413–415

migrating data, 375–377

updating view controllers for, 416–437

using multiple, 370

many-to-many relationships, 373, 374

mapping model, 375–377

memory management, 89–98. See also ARC

allocating memory for instantiating objects, 68

automating with ARC, 91–98

blocks in, 116

freeing up unneeded memory, 132

garbage collection vs. ARC, 92

iOS difficulties with, 89–90

objects and retain counts for, 90–91

properties and, 80

reducing Core Data overhead, 398

retain attributes inoperable with ARC, 80

SQLite persistent store improvements for, 396

UIViewController subclass loading and reloading of nibs, 165

using UIWebView text handling, 227, 228

view loading and, 180

merging

conflicting data, 305, 308–320

data changes from iCloud, 406

iCloud support for three-way, 394–395

message pop-up views, 506–507

metadata for geotag, 508–510

methods, 71–79

adding dynamically to objects, 75

autorotating and autosizing, 170–172

browsing inherited, 67

called with low memory warnings, 132

calling, 73–75

class, 74, 148

convenience, 78–79

creating and using selector for, 75

declaring with protocol, 84

delegate, 102–103

hidden arguments for, 74

implementing in extensions, 88

initializer, 75–78

instance, 138

method signatures, 74

Objective-C, 71

opening and closing, 130–132

properties, 79–83

releasing calls, 93

sending message to nil, 72

standardizing LBS_PER_KG weight displays with helper, 144–146

modal views

about, 189

displaying mail composer as, 514–517

passing data in and out of, 195–198

model

adding model objects to storyboards, 158

asynchronously accessing model object, 335–341

building classes for Health Beat, 141–157

linking to controller, 158–163

replacing model layer with Core Data, 367, 368

using as singleton, 158

Model-View-Controller framework. See MVC framework

motion events

devices supporting, 490

disabling motion updates, 496

enabling shake, 360–363

starting accelerometer updates, 492–496

multiple initialization methods of objects, 69

MVC (Model-View-Controller) framework

about, 100–101

building Health Beat model classes, 141–157

linking Health Beat model to controllers, 158–163

Objective-C’s design patterns using, 44

N

naming

auto-generated outlets, 174

init methods, 75

navigation controllers

embedding history view controller in, 136

modifying for Core Data model, 430

tab bars vs., 122

Navigator area, 11

navigator groups, 12

nested contexts, 378–379

nib-based view controllers, 458–459

.nib files

encapsulating in storyboards, –15

function of, 164–165

incompatible with loadView override, 443

methods calling, 241

storyboards vs., 14

nil values

accessing outlets without, 38

freeing up memory for property using, 34

notifications, 104–106

defined, 104

enabling and disabling KVO, 339

for fetched results controller changes, 428–429, 430

implementing, 104–105

posting manual, 155–157, 212–215

receiving from iCloud key-value store, 354

sending, 105

synchronous and asynchronous, 105–106

unregistering methods from, 350–352

NSArray collection class, 151

NSAssert, 253–255

NSFetchedResultsController, 419

NSFFileCoordinator, 287

NSKeyedArchiver objects, 298, 299

NSKeyedUnarchiver objects, 298, 299

NSLocalizedString( ) method, 531

NSManagedObject object, 380–381

NSManagedObjectModel object, 370

NSMetadataQuery, 404

NSMutableArray collection class, 151

NSNumberDate, 182

NSNumberFormatter, 147, 180, 182

NSUbiquitousKeyValueStore:, 289

NSURL objects, 279

numbers

current date formatting, 177, 180

formatting decimals, 147

restricting input of invalid, 169

O

Object library, 30

Objective-C language, 43–117

about, 5, 43–45

abstract classes, 67

attributes in Core Data and, 371

blocks, 112–116

C data structures used in, 49–53

C data types used in, 46–48

case sensitivity of, 51

categories and extensions in, 86–88

declaring class interfaces, 69–70

delegates, 101–104

enumerations, 54–56

exceptions used in, 147

functions, 58–63

key elements of, 46

key-value coding, 106–107

key-value observing, 107–108

memory management in, 89–98

methods, 68, 71–79

MVC framework and, 44, 100–101

.nib file technology in, 164–165

notifications, 104–106

objects, 64–70

operators, 56–58

order of operator precedence, 57–58

properties, 79–83

protocols, 83–85

recommended documentation for, 45, 117

refactoring code in, 149

required knowledge of, 45

single and double quotes in, 51

singletons, 109–112

objects, 64–70

adding and removing from weightHistory array, 157

adding user interface, 30

asynchronous accessing of, 335–341

calling methods on class, not, 74

classes vs., 64

defining class for, 69–70

delegate, 21

duplicating bouncing, 469

dynamically adding methods to, 75

encapsulating, 64–65

graph of Hello World, 29

handing context to, 379

implementing class definitions, 69, 70

inheritance for, 65–67

instantiating, 68–69

loading custom, 164

managed, 379–385

memory cycles for, 92–95

multiple initialization methods for, 69

NSURL, 279

optimizing large data, 398–399

receiving notifications, 104

removing from tables, 218–220

retain counts for, 90–91

saving object hierarchies, 296

one-to-one relationships, 373

opaque property, 244, 245

OpenGL ES, 253

opening

and closing apps, 130–131

iCloud documents, 321

operands, 56, 57

operators, 56–58

order of precedence, 57–58, 59

orientation

autorotating to interface, 25, 26

calculating animation rotations, 462–463

changing GravityScribbler, 496–498

launch screen, 526

positioning pop-up views, 464–465

rotating graph views, 267–268

rotating Twitter image, 516–520

selecting supported device, 125

setting view’s autorotating and autosizing methods, 170–172

outlets

accessing safely, 38

creating and configuring Hello World, 32–34

deleting connection to delegate, 28

EnterWeightViewController, 173–174

format for naming auto-generated, 174

providing gesture recognizer, 184

setting with nibs, 165

P

pan gestures, 481, 486–489

paths

creating to resource files, 278

generating directory, 272–273, 276–277

key, 106, 107–108, 154

manipulating, 279–282

NSURL objects vs. string-based, 279

pause gesture, 482–483

pause view controller, 458

performance

alert view effect on, 507

minimizing objects saved and loaded, 298

NSAssert effect on, 254

optimizing Core Data, 396–400

speed of GCD’s dispatch_sync, 445–446

when to load and save apps, 306–307

performSegueWithIdentifier:sender: method, 19

persistent store coordinator, 389–392

persistent stores

creating incremental, 392

encrypting data on disk, 393

fetch request round trips to, 388

iCloud three-way merges for, 394–395

setting up iCloud and local URL for, 402–403

types of, 390–392

placeholders, 68, 458

plists (property lists), 6

pointers, 49, 62–63

polishing apps, 524–537

building distribution code, 535–536

file sharing, 533–534

icons, 524–525

including accessibility support, 532

launch images, 525–526

listing required features, 527–528

localizing features, 530–532

providing iTunes artwork, 527

specifying deployment target, 528–530

submitting to iTunes App Store, 536–537

pop-up views

acceleration, 471–474, 486–487

adding bounce animation to, 466–469

animation sequences in, 460–462

changing orientation of, 496–498

creating, 457–460

defined, 457

hiding, 469–470

message, 506–507

positioning, 464–465

starting animation in, 463–464

#pragma mark directive, 153, 154, 155

predicates, 385–387, 388

preferences

adding page for, 355–359

managing user, 283–284

syncing between machines, 352–355

prepareForSegue:sender: method, 25, 26, 37

preset tab bar items, 136

privacy

asking permission for geotagging, 500, 501, 502

location tracking and, 499

productivity apps, 120–122

progress views, 471–474

projects

adding QuartzCore framework to, 198

choosing location for, 9

creating, 8–10, 123–124

error testing for, 407

git repository for, 9

running static analyzer on, 126–128

selecting supported device orientation, 125

workspaces for, 7

Xcode and iOS SDK versions used in book, 6

properties

advantages of, 79

browsing inherited, 67

common attributes of, 80

Core Data, 370–375

declaring in class interface, 79

defining graph view, 238–239

delegate, 101

dot notation with, 82, 83

extensions for declaring new, 88

opaque, 244, 245

redeclaring, 88

synthesizing graph view, 240

synthesizing virtual, 152, 159

updating view controllers with Core Data, 416

protocol methods, 103

protocols, 83–85

adopting, 84–85

conforming text to UITextFieldDelegate protocol, 173–174

declaring, 85

declaring methods with, 84

UIAppearanceContainer, 473

Q

QuartzCore framework, 198

queries for iCloud files, 328–334

Quick Help inspector, 22

R

readonly/readwrite attributes, 88

readonly/readwrite properties, 233

redeclaring properties, 88

refactoring, 149

relationships

creating, 135

defined, 19

defining connections with entities using, 372–373

one-to-one or many-to-many, 373, 374

segues vs., 135

reset, 398

resetting canvas, 456–457

resizable images, 474, 475, 477

resizing labels, 31

responding to user input, 478–498

changing orientation of pop-up view, 496–498

gesture recognizers, 481–489

triggering touch-based events, 479–480

using Core Motion, 490–498

retain cycles

defined, 92

retain counts for objects, 90–91

searching for, 94–95

using ARC rules for, 80, 95–96

zeroing weak references for, 93–94

Retina display

drawing for, 252–253

high-resolution images for, 474, 475, 476

1-point lines in, 250

rotations

autorotating to interface, 25, 26

calculating animation, 462–463

graph views, 267–268

rotating image in Twitter, 516–520

setting view’s autorotation methods, 170–172

rounded rectangles

drawing grid in, 248–251

rounding view’s corners, 198–203

runtime

adding method to implementation at, 71

Objective-C characteristics at, 44

using @dynamic directive at, 82

S

saveWeight action, 185

saving

actions explicitly for undo manager, 416

app in background, 352

app state, 290–291

arrays with keyed archiver, 295–299

controllers for Health Beat, 133, 134

data to iCloud, 285–289

document data automatically, 287, 288

EnterWeightViewController, 133

geotagged images, 499–510

GraphicViewController, 133

knowing when apps should be, 306–307

minimizing objects saved, 298

parent and child contexts, 379

preferences, 283

resolving data conflicts when, 311–314, 319

unable to save document state, 342–343

user defaults, 348–359

values from init, 68

scenes

adding to controller and tab bar, 133, 134–135

first responder and view controller in, 16–17

initial storyboard, 17–18

passing data across segue to, 27

view controllers for, 16, 17

screen

controlling entire, 441

designating image for launch, 526

resetting views multiple times, 180

segues

attributes for Hello World, 20

checking identifier before using, 26–27

connecting storyboard to flipside view, 19

connecting tab bar to navigation controller, 136

creating generic modal storyboard, 189

defined, 19

drawing from action, 189

between Health Beat history and detail views, 162–163

passing data between scenes across, 27

relationships vs., 135

selectors, 75

self argument, 7, 74

[self alloc] method, 79

Settings app, 284, 355–359

sharing

containers among apps, 285

data via iCloud, 285–286

files, 274, 533–534

shouldAutorotateToInterfaceOrientation: method, 25–26

shouldRasterize, 204, 205

simulator for iPhone, 10

singletons

disadvantages using model as, 158

implementing, 109–112

Smalltalk, 44

SMS messages, 511

SQLite persistent stores

fetch requests to, 390–391

improving performance with, 396

key path patterns for, 392

reducing memory use with, 393

stack

about Core Data, 370

limiting size of undo, 304

persistent store coordinator’s role in, 389

using mutable array as, 159–160

Stack category, 87

state

declaring and implementing changes in document, 309–310

designating pop-up view animation, 461–462

flag disabling app editing, 342, 346–347

flags for UIDocument abstract class, 342

informing user of changes in, 342–347

monitoring change in document, 308–309

preventing user from editing app, 347

saving app, 290–291

storyboards

adding model objects to, 158

connecting history and detail views from, 162–163

defined, 14

deleting template from new app, 124–125

editing header file next to, 32

Health Beat, 137, 138

initial scene of, 17–18

nibs vs., 14

opening and editing, 15–21

use of nibs in, 164–165

using for projects, 9

Xcode changes when label and outlet added, 33–34

string-based paths, 279

stringForWeight: method, 145–150

strings, 50–51

structs, 51, 52–53

subclasses. See also specific subclasses

managed object custom, 380–381

using iCloud storage with UIDocument, 294–295

superclass

browsing inherited methods for, 67

designated initializers for classes and, 75–77

Supported Device Orientations setting, 125

swipe gesture, 183–185, 481, 483–486

switch statements, 145–146, 149

syncing

defaults across iCloud, 352–355

GravityScribbler reads and writes with GCD, 444–446

local container data to iCloud, 289

synthesizing virtual properties, 152, 159

T

tab bar

adding button images for, 128

adding new scenes to, 133, 134–135

configuring, 133–140

creating model in controller for, 158–159

navigation controllers vs., 122

using preset items for, 136

Tabbed Application template, 122, 123, 124–125

tables

accessing objects with fetched results controller, 420–423

connecting to/from prototype cells, 136–137

customizing history cells for, 206–210

designing static, 221–227

how cells work in, 210

removing rows from, 218–220

reusing cells, 139, 210

tap gesture, 481, 482–483

templates

ARC memory management in, 95

modifying attributes on, 30–32

Tabbed Application, 122, 123, 124–125

Utility Application, 8, 10, 11–12, 30–32

Xcode, 8

testing

apps with iOS Developer Program, 6

Core Data performance, 399

deployment target errors, 530

distribution builds, 535–536

drawing code on devices, 253

iOS devices, 129

projects for errors, 407

text

adding to enter weight view, 168–169

changing when flipside view dismissed, 35–36

conforming to UITextFieldDelegate protocol, 173–174

displaying output, 227–228

modifying attributes of, 31

passing between views, 36–37

runtime changes of label, 32

showing warning, 342–343

text fields

filtering input from, 186–188

making first responder, 182–183

placing and setting attributes for, 168–169

tiled images, 474–475, 476–477

toll-free bridging, 96–97

touch-based events. See also gestures

creating with gesture recognizers, 481–489

modifying behavior of, 479–480

resetting canvas with shake, 456–457

triggering undo with shake, 360–363

trend lines, 253–260

Twitter support, 170, 516–520

Type attribute, 30

U

UIAppearance proxy, 471–474

UIAppearanceContainer protocol, 473

UIApplicationDelegate protocol, 21, 22

UIApplicationMain() function, 13–14

UIControl class, 478, 479–480

UIControlState class, 178–179

UIDevice class, 497–498

UIDocument abstract class

checking for document states in, 310

creating WeightHistory subclass of, 294–295

saving and loading, 295–297, 299

state flags for, 342–343, 346, 347

tracking document changes, 300–305

UIManagedDocument subclass, 395–396, 418

using for iCloud apps, 287–288

using saveless model, 287, 300

UIKit class

customizing controls, 470–477

drawing views with, 243–244

working with modal views, 516

UIManagedDocument class, 395–396, 400–406, 418

UINavigationController class

about, 120, 121

tab bars vs. navigation controllers, 122

uses for, 122

using subclass with Core Data, 430

UITabBarController class, 120, 121, 122

UITableView class, 120, 121, 122

UITextFieldDelegate protocol, 173–174, 186–188

UIView class hierarchy, 66–67

UIViewController class

creating and configuring subclass for, 133–134

instances required for scenes and views, 17

subclass loading and reloading of nibs, 165

UIViewController container, 452–457

UIWebView text handling, 227, 228

unarchiving, 298

undo

limiting size of stack, 304

registering explicit saves for, 416

removing added weights with, 302–304

tracking changes before removing or undoing, 300–305

triggering with shake gesture, 360–363

UnitSelectorViewController subclass, 189, 193–195, 198–200

updates

accelerometer, 492–496

files copied during, 275

forcing system synchronization and, 283

history view, 211–217

HistoryViewController, 211–217, 419

location, 501–502, 503–506

weights in Health Beat graph, 264–266

URLForUbiquityContainerIdentifier: method, 286, 323–324

URLs

calculating local storage, 322–323

coordinated reading/writing block methods for, 313

manipulating paths to, 279–282

returning for iCloud documents, 324

setting iCloud, 323–324

setting up for iCloud and local storage, 401–404

Use Core Data checkbox, 8, 9

user interface. See also preferences; responding to user input

creating custom, 441

icons for, 524–525, 526

launch images for, 525–526

managing preferences for, 283–284

MVC architecture for, 100–101

saving state of, 290–291

streamlining enter weight view, 169

updating when default changes, 350

users

controlling cursor, 490–498

resetting canvas with shake, 456–457

saving defaults set by, 348–359

setting up iCloud account, 286

Utility Application template

about, 10

choosing, 8

files created by, 11–12

modifying attributes on, 30–32

utility apps, 120

V

view controllers

accessing custom view properties and instance methods, 264–266

adding outlet to, 32–34

content vs. container, 452

deleting template elements from, 124–125

designing for flexibility, 160

embedding in navigation controller, 136

Hello World, 18, 19, 20

instantiating and assigning to fetched results controller, 425–426

linking Health Beat model to, 158–163

nib-based, 458–459

outlet access from, 38

relationship added to, 135

scene, 16, 17

updating managed object model, 416–437

working with child, 453, 454, 456, 460

view hierarchy

separating dynamic and static views, 442–450

subclassing UIControl and multi-layer, 479–480

using layers in, 452–453

view object, 19

viewDidAppear: method, 180–182

viewDidLoad: method, 159–160, 164, 180

viewDidUnload: method, 180

views. See also graph views; pop-up views

adding rounded corners to, 198–203

animating with blocks, 112

autorotating and autosizing for, 170–172

creating graphics context with each drawing, 248

drawing custom control in multi-layer, 479

drawing grid in rounded rectangle, 248–251

Health Beat’s first, 124

Hello World main and flipside, 10, 40

how nibs load, 164

locking control to top of, 171

modal, 189, 195–198

modifying Hello World main, 30–31

multi-layer, 479–480

opaque property for, 244, 245

pause, 459

progress, 471–474

rendering offscreen, 204, 205

rotating graphic, 267–268

separating dynamic and static, 442–450, 452

view controllers for, 17

viewWillAppear: method, 180–182

viewWillLoad: method, 37

W

warnings, 128, 342–343

website for book, 537

WeightEntry class, 141–150

converting weights for, 144–146

declaring and implementing, 141–143

defining weight units for, 142

function of, 141

generating custom Core Data, 410–416

implementing WeightEntry managed objects, 412–413

initializing objects in, 142–143

instantiating managed objects, 413–415

refactoring code in, 149

wrapping WeightEntry objects in GraphStats class, 232–237

WeightHistory class

accessing WeightHistory objects, 325–327

adding, 150–157

adding and removing objects from array, 157

adding virtual weights properties, 153–157

asynchronously accessing WeightHistory objects, 335–341

compatibility with UIManagedDocument, 417–418

function of, 141

monitoring changes in weight values with KVO, 154, 155–157

opening documents with single method call, 321–334

renaming and replacing files for, 400

setting defaults with accessor methods, 155

WeightHistory subclass, 294–295

weights

adding and removing, 155–157

calculating coordinates for, 262–263

converting pounds and kilograms, 142–149

creating single-entry trend lines for, 253–256

drawing full trend lines for, 257–260

entering unit, 174–176

enumerating properties for, 142–143

graph updates for, 264–266

history view updates when units change, 211–217

importing and synthesizing weightHistory property in all controllers, 161–162

removing from history view, 218–220

setting default units for, 154

virtual properties for, 152, 153–157, 159

WeightUnits object, 348–349

workspaces, 7

X

Xcode

about, 5, 6

adding outlet to view’s controller, 32–34

auto-selecting companion files in, 33

converting non-ARC apps to ARC, 95

Disclosure Indicator and Detail Disclosure in, 207

downloading, 129

fetch requests in, 377

getting to know documentation for, 99

launching app in simulator, 10

localization with, 531

naming auto-generated outlets, 174

navigator groups in, 12

opening and editing storyboards in, 15–21

placing controls in, 31

precompiled prefix header files for, 12

preset tab bar items for, 136

running static analyzer on code, 126–128

starting projects in, 8–10

version used in projects, 6

workspaces in, 7

.xib files, 15

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset