1. Trang chủ
  2. » Công Nghệ Thông Tin

Phát triển ứng dụng cho iPhone và iPad - part 40 docx

10 215 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 1,19 MB

Nội dung

359 paper design, 22 populating, 26–31 records, creating, 26–28 rows inserting, 27 reading, 28–31 strings, retrieving, 44 text, retrieving, 44 visualizing, 31–33 writing to, 49 datasource, 12 dateChanged method, 198 dates, EditDateController, 195–199 DBAccess class, 38 database reference, 38–39 DBAccess.m code, 45–47 DCOM (Distributed Component Object Model), 304 dealloc method, 96, 170 debugging Interface Builder, issues, 169 scrolling, 85 delegates, 15 connectionDidFinishLoading, 287 connection:didReceiveData:, 274 NSURLConnection, 278–282 parsing, 288–291 updates and, 261 Delete Rule drop-down, 152 deserialization, 117–118 design patterns, 17 Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et. al.), 17 designing database, 22–24 threading and, 246–247 Destination drop-down box, 151 Detail View Controller, 94 detailDescriptionLabel, 96 detailItem instance variable, 95 detailItem property, 95 details for records, 90 detailTextLabel property, 58 DetailViewController, 91, 95 #import statements, 102 master-detail interface, 97–98 DetailView.xib fi le, 95 development, 236 device location, copy, 312 device orientation, 92–93 dialog boxes New File, 171–172 New Mapping Model File, 243 New Project, 4 didEndElement method, 290 didSelectRowAtIndexPath method, 199 directories, applications, 115 discrete gestures, 110 dismissing keyboard, 335 displaying data catalog, 22, 50–52 delegates, 15 item count, 51 popovers, 103–110 protocols, 12 UITableViewDataSource, 13 @distinctUnionOfArrays function, 222 @distinctUnionOfObjects function, 222 DOM (Document Object Model), 284 DOM parser, 284 dot-separated strings, 220 downloads, Xcode, 4 drawAtPoint: method, 70 drawing cells, custom, 88 drawRect method, 69–70, 88 DTD (Document Type Defi nition), 283 DTrace, 344 dueDate property, 213 dynamic properties, 211–212 @dynamic statement, 172 databases – @dynamic statement bindex.indd 359bindex.indd 359 9/17/10 7:26:03 PM9/17/10 7:26:03 PM 360 E EditDateController, 195–199 editing controllers, 180 EditDateController, 195–199 EditLocationController, 189–194 EditPriorityController, 185–188 EditTextController, 181–185 editing text, EditTextController, 181–185 EditLocationController, 189–194 EditPriorityController, 185–188 EditTextController, 220 editing text, 181–185 NSManagedObject, 181 NSManagedObjectContext: method, 181 encapsulation, 7 entities abstract, 148 attributes, 149–150 details, 147–149 Event, 170 inheritance, 260 relationships, 150–153 Task, 170 entitiesForConfiguration method, 148 entity property, 148 Entity-Relationship Diagram, 146–147. See ERD (Entity-Relationship Diagram) ERD (Entity-Relationship Diagram), 22 error data, Persistent Store Coordinator, 129 error handling, Web-based services, 273 errors, Core Location framework, 311 evaluateWithObject method, 232 Event entity, 131, 170 changing to Task entity, 137 executing statements, 43 expressions, building, 149 extractTerms method, 333, 335 F faulting, 124, 258–259 Fetch Request templates, 155 fetch requests, stored, 202 Fetched Properties, 153–154 arrays, 202 highPriTasks, 172 fetchedResultsController accessor method, 170, 207 property, 132–133 sort descriptor and, 203–204 fi elds, validation, 213–217 fi le sharing, enabling, 115 fi les, XML, 283 fileURLWithPath: method, 129 filteredArrayUsingPredicate: method, 233 fi ltering, results, NSPredicate, 204–205 fi lters, arrays, 81 fl attening arrays, 82 folders, organizer, 5 foreign key constraints, 26 functions @avg, 221 bind functions, 48 collection operators, 221–222 @count, 221 @distinctUnionOfArrays, 222 @distinctUnionOfObjects, 222 keypaths, 221 list functions, 221 @max, 222 @min, 222 parseXML, 340 @sum, 222 @unionOfArrays, 222 @unionOfObjects, 222 @unionOfSets, 222 xmlDocDumpFormatMemory, 297 xmlNewChild, 295 xmlNewComment, 296–297 EditDateController – functions bindex.indd 360bindex.indd 360 9/17/10 7:26:04 PM9/17/10 7:26:04 PM 361 xmlNewDoc, 295 xmlNewProp, 296 G garbage-collected languages, 170 garbage-collection, 346 generateXML method, 298–299 gesture recognizers continuous gestures, 110 discrete gestures, 110 UIGestureRecognizer class, 110–111 GET requests, 332, 336 getAllProducts method, 38, 40 getNameAtIndex interface method, 9 getRowCount interface method, 9 implementing, 10–11 goPressed method, 353 grouped tables, NSFetchedResults Controller, 205–211 groups, 172 GUI interface, 31 H handleSwipeLeft method, 112, 114 handleSwipeRight method, 112, 114 highPriTasks fetched property, 172 Horstmann, Cay S., Object-Oriented Design and Patterns, 17 HTML (HyperText Markup Language), consumers, 305 HTTP (Hypertext Transfer Protocol), 272 Human Interface Guidelines, 92–93 I IBAction methods, 275 IBOutlet properties, 309 implementation, lookup, 10 @implementation block, 10 import statement, 38 CatalogProductView header, 67 #import statement, 9 #import statements, DetailView Controller, 102 importing data fi les, to databases, 28 indentationLevel property, 61 indenting text, 61 Indexed checkbox, 150 indexes, 72–78 infoButton, 107 infoLabel property, 105 infoPopover property, 108 InfoViewController class, 105 inheritance, entities, 260 init method, 10, 39 initializeDatabase method, 38 initWithFrame: method, 68 INSERT command (SQL), 26–28 insertNewLocation method, 190 insertNewObject method, 136, 251–252 instances, model classes, 13–15 Instruments, 264, 343–344 Detail pane, 346 interface, 266–267 memory leaks, 347–348 analyzing, 349–351 MemoryLeaker, 348–349 Objective-C, 346–348 playhead, 345 RandomNumbers project, 264–265 starting, 264–266, 344 trace document, 345–346 Interface Builder, 6 debugging, issues, 169 documentation, 57 Library palette, 310 outlets, 52 @interface declaration, 225 interfaces declaration, 168 Human Interface Guidelines, 92–93 functions – interfaces bindex.indd 361bindex.indd 361 9/17/10 7:26:05 PM9/17/10 7:26:05 PM 362 interfaces (continued) Instruments, 266–267 master-detail, 34 methods getNameAtIndex, 9 getRowCount, 9 mockup, 33–34 objects, decoupling, 224 UILabels, 53 Xcode Data Modeling tool, 146 Inverse drop-down, 151 iPhone, master/detail displays, 90 iPhone SDK URL Loading System, 273–275 Web and, 271–282 iPhone SDK Programming: Developing Mobile Applications for Apple iPhone and iPod Touch (Ali), 52 isOverdue property, 172, 179, 211–212 J Java RMI (Remote Method Invocation), 304 JDBC, 304 joining databases, 30–31 JSON (JavaScript Object Notation), 305 Array, 305 Object, 305 K key-value coding. See KVC (key-value coding) key-value observing. See KVO (key-value observing) keyboard, dismissing, 335 keyboard shortcuts, Xcode, 9 KeyPath parameter, 223 keypaths, 220–221 functions, 221 location.name, 220 nil key, 221 objects nested, 220 references, 221 predicates, 232 values from objects, 221 keys, 220–221 NSDictionary, 224 keyString, 181 keywords @dynamic, 158 SQL, 27 @synthesize, 158 KVC (key-value coding), 136, 219 managed objects, 181 NSKeyValueCoding protocol, 220 NSManagedObject, 220 To-Many relationships, 222 To-One relationships, 222 value setting, 221 value updates, 229–231 KVO (key-value observing), 219, 222–223 callbacks, 223 example, 224–231 implementing, 223 automatic, 224 manual, 224 NSObject class, 223 automatic implementation, 224 Umpire application, 227–229 L labels, text, setting, 53–54 layout, hand-coding, 62 Library palette, 310 libsqlite framework, 40 libxml, 291–292 web site, 300 lightweight migration, 239–242 lineBreakMode, 70 list functions, arrays, 221 interfaces – list functions, arrays bindex.indd 362bindex.indd 362 9/17/10 7:26:05 PM9/17/10 7:26:05 PM 363 lists, sort descriptors, 233 loadView method, 7, 15 local search API, 313–315 location-based search, 308–331 Location object, editing text, 181 location.name keypath, 220 locations, EditLocationController, 189–194 LocationSearch application, 308 Core Location framework, 308, 310–313 interface, building, 310 local search API, 313–315 MapKit framework, 308, 327–331 search bar, 315–318 user interface, 309 web services, 304–306 response, 318–331 REST, 307–308 SOAP messaging, 306–307 URI schemes, 307 LocationSearchViewController class, 309 LocationTasksViewController, 165, 206 lookup implementation, 10 M mainBundle method, 39–40 MakeXML application, 293–300 MakeXMLViewController, 294–300 Managed Object Context (Core Data), 124, 126–127 threading and, 248 Managed Object Model (Core Data), 124, 126 getter function, 130 managedObjectContext getter method, 130 managing memory, 170–171 MapKit framework, 308, 327–331 mapping model, 236 generating, 242–246 mapping type, 242 Show Differences button, 244 Mapping Model tool, 244–245 mapView property, 309 master-detail interface, 34 DetailViewController, 97–98 iPhone, 90 RootViewController, 99 Table View, 100–101 master records, tapping, 90 @max function, 222 memory allocating, arrays, 10 autorelease message, 41 releasing, 170–171 memory leaks, 347–348 MemoryLeaker, 348–349 memory management, 170–171 Memory Management Programming Guide for Cocoa, 41 MemoryLeaker application, 348–349 method signatures, 38 methods addGestureRecognizer, 112 addSurvey, 96, 102 addSurvey:, 97–98 addSurveyToDataArray, 101 applicationWillTerminate, 115 awakeFromInsert, 212 buttonTapped, 229–231, 275 cellForRowAtIndexPath, 14 cellForRowAtIndexPath:, 61 cleanup, 170 clearSurvey, 96 clearSurvey:, 97–98 closeDatabase, 38 compare:, 233 configureCell, 249–250 configureView, 98 connectionDidFinishLoading, 319 controllerDidChangeContent, 169 lists, sort descriptors – methods bindex.indd 363bindex.indd 363 9/17/10 7:26:06 PM9/17/10 7:26:06 PM 364 methods (continued) controllerDidChangeContent:, 262 controllerWillChangeContent:, 262 coordinate, 322 dateChanged, 198 dealloc, 96, 170 didEndElement, 290 didSelectRowAtIndexPath, 199 drawAtPoint:, 70 drawRect, 69–70, 88 entitiesForConfiguration, 148 evaluateWithObject, 232 extractTerms, 333, 335 fetchedResultsController, 170 fileURLWithPath:, 129 filteredArrayUsingPredicate:, 233 generateXML, 298–299 getAllProducts, 38, 40 goPressed, 353 handleSwipeLeft, 112, 114 handleSwipeRight, 112, 114 IBAction, 275 init, 10, 39 initializeDatabase, 38 initWithFrame:, 68 insertNewLocation, 190 insertNewObject, 136, 251–252 interface getNameAtIndex, 9 getRowCount, 9 loadView, 7, 15 mainBundle, 39–40 managedObjectContext, 130 moveNext, 112–114 movePrevious, 112–114 NSManagedObjectContext:, 181 NSPredicate, 231–232 numberOfRowsInSection, 14, 51 numberOfSectionsInTableView, 81, 175, 208 numberWithBool, 212 objectForKey, 98 parserDidEndDocument, 284 parserDidStartDocument, 284 parseXML, 333 persistentStoreCoordinator, 128, 240 plotResults, 327 predicateWithFormat, 231 saveButtonPressed, 197 setLabelsForProduct, 53 setProduct:, 68 setText, 105 setValue:forKey:, 222 showInfo, 107 sortedArrayUsingDescriptors, 234 sqlite3_close, 40 sqlite3_finalize, 45 sqlite3_open, 40 sqlite3_prepare_v2, 43 stopUpdatingLocation, 311–312 stringValue, 98 stringWithFormat, 317 TableView, 36, 51, 179 TableViewCell, 51 tableView: cellForRowAtIndexPath:, 175 tableView: numberOfRowsInSection:, 175 toolbar invoking, 168–169 toolbarFilterAll, 205 toolbarFilterWiPri, 204–205 toolbarSortOrderChanged, 203–204 validateForInsert, 215 validateForInsert:, 159 validateForUpdate, 215 validateForUpdate:, 159 valueForKey, 220 valueForKey:, 222 valueForUndefinedKey:, 220 viewDidLoad, 50–51, 74–75, 174, 182 viewDidUnload, 170 methods – methods bindex.indd 364bindex.indd 364 9/17/10 7:26:06 PM9/17/10 7:26:06 PM 365 viewDidUnload method, 190 viewWillAppear, 174 viewWithTag, 65 xmlCleanupParser, 298 migrating data between databases, 25 migration, lightweight, 239–242 @min function, 222 MKAnnotation protocol, 321 MKCoordinateRegion, 329 model classes, 6–7 controller classes and, 6–7 instances, 13–15 model versioning, 235–236, 236, 237–239 model-view-controller architecture, 6–7 user interface, 7 models, compatibility, 237 moveNext method, 112–114 movePrevious method, 112–114 mutable strings capturedCharacters, 291 parsing and, 286 MVC design pattern, 36 myTextFile.txt, 18 N n-tier architecture, 303–304 naming conventions, 222 Nav Bar control, 174 Navigation-based Application template, 4 Navigation Controllers hierarchical data, 4 master-detail display, 90 Title property, 52 View Controllers, 34 navigation stack, 34 Navigation template, projects from, 36 nested objects, keypaths, 220 network application architecture, 301–302 application communication, 304 three-tier, 303–304 two-tier architecture, 302–303 New File dialog box, 171–172 New Mapping Model File dialog box, 243 New Project dialog box, 4 nil key, 221 nil property, 170 nodes AttributedChild, 296 ChildNode1, 295 root node, 295 normalization of data, 22 independent, 22 over-normalizing, 24 notifi cations KVO, 223 property changes, 223 NSArray, 40, 99 entities, 148 NSBinaryStoreType, 129 NSBundle class, 39–40 NSData class, 275 NSDictionary building, 103 observed object changes, 224 surveys, 98 NSEntityDescription, 148 NSEntityMapping class, 242 NSError object, 129, 159 NSFetchedResultsController class, 132, 205–211, 261 NSFetchedResultsControllerDelegate protocol, 206 NSInferMappingModelAutomatically Option, 240 NSInMemoryStoreType, 129 NSKeyValueCoding protocol, 220 NSManagedObject class, 211 entity property, 148 KVC, 220 Location subclass, 165 migrating data between databases – NSManagedObject class bindex.indd 365bindex.indd 365 9/17/10 7:26:07 PM9/17/10 7:26:07 PM 366 NSManagedObject class (continued) subclasses custom, 155–159 generating, 171–172 Task subclass, 165 NSManagedObjectContext: method, 181 NSManagedObjectContext class, 126–127 NSManagedObjectModel class, 126, 148 NSMappingModel class, 242 NSMigratePersistentStores AutomaticallyOption, 240 NSMutableArray class, 40 filteredArrayUsingPredicate:, 233 NSNotification class, 223 NSNumber class, 211, 222 NSObject class, KVO and, 223 automatic implementation, 224 NSOperation class, threading and, 248–249 NSPredicate class, 81, 124, 204–205 NSPredicate class method, 231–232 NSPropertyListSerialization class, 116 NSPropertyMapping class, 242 NSSet, 157 NSSortDescriptor, 134, 203–204 NSSQLiteStoreType, 129 NSString, keyString, 181 NSStrings, 103 NSUndefinedKeyException, 220, 221 NSURL class, 273–275 NSURLConnection class, 274 callbacks, 316 NSURLConnection delegate methods, 278–282, 318–320 NSURLRequest class, 318 objects, initializing, 274 NSURLRequest classes, 273–275 NSURLRequest object, 277 NSValue class, 222 NSXML parser, 283–285 NSXMLParser class, 284, 341 numberOfRowsInSection method, 14, 51 numberOfSectionsInTableView method, 81, 175, 208 numberWithBool method, 212 numeric data types, 149 O Object-Oriented Design and Patterns (Horstmann), 17 object-oriented programming (OOP), 7 objectForKey method, 98 Objective-C autorelease message, 347 Instruments, 346–348 memory management rules, 347 retain count, 346 retainCount message, 347 Objective-C class, 8 objects changes, observing, 223–224 custom managed, 211–217 encapsulation and, 7 interfaces, decoupling, 224 nested, keypaths, 220 NSError, 129, 159 Product, 52 references, keypaths, 221 retrieving values, keypaths, 221 values, 220 bulk retrieval, 221 xmlDocPtr, 294 Observer parameter, 223 observers, classes as, 223 ODBC (Open Database Connectivity), 304 OmniGraffl e, 22 OOP (object-oriented programming), 7 opaque views, 68 subviews, 86–87 options parameter, 223 NSManagedObject class – options parameter bindex.indd 366bindex.indd 366 9/17/10 7:26:08 PM9/17/10 7:26:08 PM 367 organizer, 5 orientation of device, 92–93 outlets, 52 ProductDetailViewController .xib fi le, 53 UITextView, 286 owning reference, 352 P parameterized queries, 47–49 parameters BAD_CAST, 295 binding, 48 cachePolicy, 277 context, 223 KeyPath, 223 Observer, 223 options, 223 permittedArrowDirections, 109 sectionNameKeyPath, 207 parserDidEndDocument method, 284 parserDidStartDocument method, 284 parseXML function, 340 parseXML method, 333 parsing delegate methods and, 288–291 DOM parser, 284 mutable strings and, 286 XML, 283–285, 285–291 response, 340–342 SAX (Serial Access Parser), 284 web services response, 322–326 patterns delegation, 15 design patterns, 17 perceived performance, 258 performance entity inheritance, 260 faulting, 258–259 perceived performance, 258 runtime, 260–261 permittedArrowDirections parameter, 109 Persistent Store Coordinator (Core Data), 124, 125–126 error data, 129 existence checking, 129 threading and, 248 persistentStoreCoordinator accessor method, 240 persistentStoreCoordinator getter method, 128 persistentStoreCoordinator method, 240 playhead (Instruments), 345 plotResults method, 327 pointers, context parameter, 223 popoverContentSize property, 106 popovers dismissing, 103 displaying data in, 103–110 permittedArrowDirections parameter, 109 size, 106–107 text, 105 POST requests, 332 implementing, 335–338 predicates, 219 creating, 231–232 evaluateWithObject method, 232 keypaths, 232 predicateWithFormat method, 231 priorities, EditPriorityController, 185–188 processor speed, 85 Product class, 36–37, 52 product details in catalog, 52–55 Product entity, 149–150 Product object, passing, 52 ProductDetailViewController header, 52–53 organizer – ProductDetailViewController header bindex.indd 367bindex.indd 367 9/17/10 7:26:09 PM9/17/10 7:26:09 PM 368 ProductDetailViewController.xib fi le, 53 products array, 41 object count, 76 products property, retain attribute, 50 Professional Xcode 3 (Bucanek), 168 project window, 5–6 projects classes, creating, 8 New Project dialog box, 4 Xcode, 4 properties accessor methods and, 220 backgroundView, 61 catalogProductView, 67 changes, notifi cations, 223 contentSizeForViewInPopover, 106 contentView, 62 coordinate, 322 detailItem, 95 detailTextLabel, 58 dueDate, 213 dynamic, 211–212 entity, 148 existence at compile time, 156 Fetched, 153–154 fetched, arrays, 202 fetchedResultsController, 132–133 highPriTasks, 172 IBOutlet, 309 indentationLevel, 61 infoLabel, 105 infoPopover, 108 isOverdue, 172, 179, 211–212 mapView, 309 nil, 170 popoverContentSize, 106 products, 50 reponseData, 318 responseData, 336–337 searchBar, 309, 315 selectionStyle, 61 sort descriptors, 233 subtitle, 322 synthesizing, 50, 174 tableview, 169 taskTableView, 169 textLabel, 58 textView, 287 Title, 52 protocols, 12 CLLocationManagerDelegate, 311 data display, UITableView DataSource, 13 MKAnnotation, 321 NSFetchedResultsController Delegate, 206 NSKeyValueCoding, 220 UISplitViewControllerDelegate, 92–93 public variables, 7 Q queries, parameterized, 47–49 query requests, XML response, 314 question marks (?), 48, 317 R RandomNumbers project, Instruments and, 264–265 RandomOperation class, 252 reading from text fi les, 18 reading rows, 28–31 recognizing gestures continuous gestures, 110 discrete gestures, 110 UIGestureRecognizer class, 110–111 records (databases) creating, 26–28 ProductDetailViewController.xib fi le – records bindex.indd 368bindex.indd 368 9/17/10 7:26:09 PM9/17/10 7:26:09 PM . 148 Entity-Relationship Diagram, 146–147. See ERD (Entity-Relationship Diagram) ERD (Entity-Relationship Diagram), 22 error data, Persistent Store Coordinator, 129 error handling, Web-based services,. (JavaScript Object Notation), 305 Array, 305 Object, 305 K key-value coding. See KVC (key-value coding) key-value observing. See KVO (key-value observing) keyboard, dismissing, 335 keyboard shortcuts,. 151 iPhone, master/detail displays, 90 iPhone SDK URL Loading System, 273–275 Web and, 271–282 iPhone SDK Programming: Developing Mobile Applications for Apple iPhone and iPod Touch (Ali), 52 isOverdue

Ngày đăng: 04/07/2014, 21:20