<<

Index

Apple Forums, 370 • A • Apple Partition Map, 103 About Bundle, 95 application bundle, 248 About Menu, 90 Application item, 68 About My Application, 90 Application menu, 75–77 About Panel Application template, 20–21 copyright date in, 95–96 applications. See also applications, credits in, 96–97 document-based icon, 92 adding code to, 36–37 information in, 90 building, 37–39, 60 setting name or title in, 92 building interface, 23–25 version number in, 94–95 code reuse, 366 accessor method, 128 copyright date, 95–96 AccountController class creating disk image, 102–105 adding actions to, 141–142 creating in six steps, 17–19 adding outlets to, 141–142 creating interface, 23–25 adding to project, 331–332 credits, 96–97 changing Object class to, 336–337 debugging, 37–39 connecting interface, 143 idea for, 19–20 creating fi les for, 145 information, 90 naming, 141–142 overview, 247–248 running application, 147 preparing menu for, 74–77 specifying superclass for, 146 sending e-mail from, 288–289 actions setting icon, 92 adding, 31, 122 setting name or title, 93–94 connecting to interface, 35, 81–83, starting with project, 20–22 304–305 version number, 94–95 defi ning, 31 applications, document-based ADC (Apple Developer Connection), 8, 368 adding code, 325–327 addObject method, 195 building and running, 321 Address Book, 71 creating interface, 322–325 Adobe Photoshop, 98,COPYRIGHTED 225 creating MATERIAL new document, 321 AIFF fi le, 296, 301, 313 creating new project, 317–318 All-in-One layout (), 44 interface, 322–325 alloc method, 117–118, 129 location, 318 animation, 183 MyDocument class, 318–321 AppKit, 224 overview, 317 AppKit Framework, 9 running, 321 Apple Developer Connection (ADC), 8, 368 applyCheckbox outlet, 204 372 Cocoa Programming for Mac OS X For Dummies

arguments, 115 bevel buttons, 174–175 arrays. See also data types Beziér paths, 230–231 adding items to, 195 bezierPathWithOvalInRect inserting objects, 195 method, 231 mutable, 194–195 bezierPathWithRect method, 230 NSArray, 193–194 bindings NSMutableArray, 193–194 defi ned, 330 overview, 192–195 implementing, 334–340 removing items from, 195 key-value coding, 333–334 replacing elements of, 195 key-value observing, 333–334 arrayWithObjects method, 193 overview, 329 aString parameter, 113 setting up in Interface Builder, 335–340 attributes, 344–347 starting project with, 331–332 Attributes Inspector, 140 blackColor, 224 Attributes window, 65–66 Blank Disk Image, 102 audio. See also audio player blogs loading sound fi les, 297–298 Call Me Fishmeal, 369 overview, 295–296 Cocoa Is My Girlfriend, 368 playing system sounds, 296–297 Dan Wood: Eponymous Weblog, 370 audio player (Cocoa project) Domain of the Bored, 369 adding stop functionality, 302–303 Theocacao, 369 attributes, 299 blueColor, 224 buttons, 299 BMP fi les, 313 connecting actions to interface, 304–305 book application (Cocoa project) interface, 299 assigning relationships, 351–353 MyAudioController class, 300–302 Author entity, 346–353 audioFileTypes array, 297 Book entity, 345–353 Automator, 71 building interface, 354–358 autorelease method, 119 Category entity, 346–353 AVI fi les, 313 creating data model, 344–350 awakeFromNib method, 151–152, 188, creating new project, 342 330, 335 isbn attribute, 347–348 Models folder, 343 naming, 342–343 • B • pages attribute, 347 backgroundColorWell outlet, 204 synopsis attribute, 347–348 balance method, 334–340 templates, 342–343 Bank Account application (Cocoa project) title attribute, 346–347 adding codes, 138–139 Bookware Quickie, 368 adding controller, 141–147 BOOL data type, 112 adding labels, 140 Boolean data type, 195–196 adding view, 139–140 breakpoints. See also debugging creating new class, 136–137 adding, 52–53 implementation fi le, 139 deactivating, 54 naming, 136–137 removing, 57–58 naming new class, 138 brownColor, 224 selecting application, 136 browser setting up bindings, 335–340 building, 283–287 title of application, 140 buttons, 286 Index 373

functions, 283 idea for, 19–20 interface, 285 naming project, 21–22 loading Web page, 280–281 removing breakpoints, 57–58 text fi eld control, 285 selecting location for, 22 Build and Debug function, 53, 60 text fi elds, 27 Build function, 60 title of application, 23–24 Build and Go toolbar, 60–61 wiring interface, 29–33 Build and Run function, 60 calibrated color, 225 built-in documentation, 58–59 Call Me Fishmeal (blog), 369 bundle, 248 center method, 151–152 Bundle Version key, 95 changeOperation action, 82, 85 Button control, 28 Class Browser, 363 buttons class method, 119 bevel, 174–175 Class models, 48 changing, 27 classes. See also specifi c classes by name check box, 171–173 adding actions to, 31, 122 label, 26 adding outlets to, 30, 122 library, 168–169 adding to interface, 31–32 overview, 167–168 connecting to interface, 33–35 push, 169–171 creating, 29–30, 119–125 radio control, 175–177 creating fi les, 124 round, 171–173 creating interface, 121–122 defi ning, 125–127 graphical model, 48 • C • implementing, 127–128 calculateAnswer action names, 130 defi ning, 31 printing, 267–268 modifying, 84–85 using, 128–129 calculator (Cocoa project) Clean command, 60 adding actions, 31 clearColor, 224 adding breakpoints, 52–53 close method, 150 adding class to interface, 31–33 closing window, 150 adding code to application, 36–37 CMYK color space, 225 adding controls to interface, 26–28 Cocoa. See also Cocoa application; Cocoa adding menu, 80–81 programming tips adding outlets to class, 30 frameworks, 9 adding pop-up menu, 78–79 Interface Builder, 13–15 application template, 21 object-oriented programming, 9 building, 37–39 overview, 8–9 building interface, 23–25 reusable codes, 9 changing codes in, 45–48 viewing in Library window, 70 connecting class to interface, 33–35 Xcode, 10–13 connecting interface, 81–83 Cocoa application creating classes, 29–30 adding code to, 36–37 creating Controller class, 81 building, 37–39, 60 creating project, 20–21 building interface, 23–25 debugging, 37–39, 51–58 code reuse, 366 fi le comments, 49 copyright date, 95–96 fi xing codes, 55–57 creating disk image, 102–105 374 Cocoa Programming for Mac OS X For Dummies

Cocoa application (continued) controller creating in six steps, 17–19 adding, 141–147 credits, 96–97 overview, 134 debugging, 37–39 Controller class, creating, 81, 120, 251–254 idea for, 19–20 controls information, 90 adding, 26–28 preparing menu for, 74–77 bevel buttons, 174–175 sending e-mail from, 288–289 buttons, 167–173 setting icon, 92 check box, 173–174 setting name or title, 93–94 overview, 167 starting with project, 20–22 progress bar, 182–183 version number, 94–95 push buttons, 169–171 Cocoa Dev Central, 370 radio control, 175–177 Cocoa Is My Girlfriend (blog), 368 round buttons, 171–173 Cocoa programming tips slider control, 178–179 Class Browser, 363 tab view, 179–182 coordinate system, 365 table, 184–189 documentation, built-in, 362–363 viewing in Library window, 70–71 drag and drop, 363–364 convenience colors, 223–224 init method, 364 coordinate system, 365 Interface Builder guidelines, 365–366 Copyright (Human-Readable) key, 95–96 keyboard shortcuts, 361–362 copyright date, 90, 95–96 superclass, 364–365 copyTheFile action, 261, 263 window count, 363 Core Data Cocoa Simulator, 75 advantages of, 342 CocoaBuilder.com, 370 building interface, 354–358 CocoaDev, 370 creating project, 342–343 Code editor, 76 defi ning model, 344–353 codes Models folder, 343 adding, 36–37, 206–208 naming project, 342–343 changing, 45–47 overview, 336–338 fi xing, 55–57 createDirectoryAtPath method, reuse, 366 265–266 Color panels, 207 credits, 90, 96–97 color space, 225 Custom Objects, 71 colorRadios, 177 cyanColor, 224 colors calibrated, 225 convenience, 223–224 • D • device, 224 Dan Wood: Eponymous Weblog, 370 device independent, 225 darkGrayColor, 224 preset, 224 data types colorWithDeviceRed function, 225 arrays, 192–195 Column view (Project window), 67–68 Boolean, 195–196 comments, 49 dates, 196–197 Condensed layout (Xcode), 44 number, 191–192 connections, 33–35 dataOfType method, 327 Console window, 44–45 dataWithContentsOfFile method, 219 Control + drag operation, 33–34 dataWithPDFInsidedeRect method, 278 Index 375 date conversion specifi ers, 197 creating interface, 322–325 dates, 196–197 creating new document, 321 Deactive Breakpoints command, 54 creating new project, 317–318 dealloc method, 119 interface, 322–325 Debug tab, 53 location, 318 debugging MyDocument class, 318–321 adding breakpoints, 52–53 overview, 317 building applications and, 37–39 running, 321 fi xing codes, 55–57 DocumentType entry, 325 removing breakpoints, 57–58 Domain of the Bored (blog), 369 runtime errors, 51 doubleValue method, 192 steps in, 51, 53–55 downloading, 281–283 syntax error, 51 drawAString method, 113 Default layout (Xcode), 44–45 drawAtPoint method, 239 delegates, 165–166 drawing text, 239–242 deliverMessage method, 291 drawRect function, 230, 235, 245, 269 description method, 196 Driver class descriptionWithCalendarFormat creating, 120 method, 196–197 defi ning, 125–127 Design window implementing, 127–128 functions, 66 testing, 130 launching, 66 using, 128–129 overview, 65–66 viewing, 68–69 determinate progress indicator, 182–183 • E • device colors, 224 Editable attribute, 308 DeviceCMYK color space, 225 e-mail DeviceRGB color space, 225 adding functions to projects, 291–294 DeviceWhite color space, 225 sending from client, 288–289 directories, 248 sending from Cocoa application, 286–294 DiscRecording, 71 sending from own apps, 290–291 disk image URL, 288 creating, 102–105 emailField outlet, 293 encryption, 103 encoding, 216 image format, 103 encryption, 103 partitions, 103 entity, 344–346 volume format, 102 errors volume name, 102 routine, 216 volume size, 103 runtime, 51 Disk Utility, 102–105 syntax, 51, 57 Display color attribute, 308 Extensible Markup Language (XML), 91 displayAsString method, 211–212 dissolveToPoint function, 243–244 document, 247 • F • documentation, built-in, 58–59, 362–363 favorites, 50 document-based application Favorites Bar (Xcode), 50 adding code, 325–327 fi le directory, 249 building and running, 321 File Info window, 49 creating, 317–321 fi le path, 249 376 Cocoa Programming for Mac OS X For Dummies

fileAttributesAtPath method, frameworks, 9 257–258 Fusebox class fileContents instance, 327 adding action to, 36–37 FileInfoController class, 252–254, adding outlets to, 30 262–263, 266 adding to interface, 31–33 FileMerge application, 78 changing codes in, 45–48, 84–87 fi lename, 249 connecting to interface, 33–35, 81–83 fi les. See also folders creating, 29 comments, 49 fi le comments, 49 Controller class, 251–254 model, 48 copying, 262–263 creation date, 249 deleting, 264–265 • G • destination path, 262 garbage collection, 117–119 downloading, 281–283 getter method, 118 icons, 258–260 GIMP, 98 interface, 249–251 goBack function, 286 modifi cation date, 249 goForward function, 286 moving, 263–264 Graphic Converter, 98 opening and using, 249–261 graphics overview, 247–248 Beziér paths, 230–231 path, 256–258 colors, 223–227 reading from, 261 displaying, 242–245 size in bytes, 249 drawing path, 234–236 source path, 262 drawing text, 239–242 writing to, 261 fi lling paths, 231–234 File’s Owner item, 68 interface, 227–230 fill function, 235 paths, 230–239 First Responder item, 68 points, 221–222 firstName method, 128 rectangles, 222–223 Flash animation, 313 text, 239–242 float variable, 46, 55 grayColor, 224 floatValue method, 46, 192 greenColor, 224 folders group, 45 copying, 262–263 Groups & Files folder, 22 creating, 265–266 deleting, 264–265 destination path, 262 • H • moving, 263–264 header fi les, 36, 77–78, 111 overview, 247–248 Help feature, 58–59 source path, 262 Hide NewApplication menu, 74 Font Manager item, 68 hideWindow action, 150 fonts, 208–209 hiding window, 150–151 Foundation Framework, 9 HTML (HyperText Markup Foundation Kit, 191 Language), 96–97 fraction parameter, 243 Human Interface Guideline, 63, 155 Index 377

int parameter, 113 • I • integer value, 37 IBOutlet, 326 integrated development environment ICNS (icon) fi le (IDE), 41 adding to project window, 92 interface. See also interface controls assigning to projects, 97 adding class to, 31–33 building, 98–101 adding controls to, 26–28 creating, 98 adding menu, 80–81 managing, 101–102 adding outlets, 30 icns Browser, 101–102 adding pop-up menu, 78–79 Icon Composer, 98–101 building, 23–25 Icon File fi eld, 92 changing window’s title, 23 Icon view (Project window), 66–67 clients, 29–30 icons connecting actions to, 35, 304–305 assigning to projects, 97 connecting class to, 33–35 building, 98–101 connecting to actions, 35, 81–83 creating, 98 connecting to outlets, 81–83 managing, 101–102 connections, 33–35 setting in About Panel, 92 creating, 121–122 viewing, 258–260 creating Controller class, 81 IDE (integrated development creating header fi les, 77–78 environment), 41 creating implementation fi les, 78 Identity Inspector, 32 document-based applications, 322–325 image editors, 98 fi les, 249–251 Image Kit, 71 graphics, 227–230 image well, 250–251 resizing window, 24 iMovie, 157 saving, 35 implementation fi les, 36, 78 using in Xcode, 83–87 import statement, 114 wiring, 205–206 indeterminate progress indicator, 182–183 Interface Builder. See also interface indexofTabViewItem, 181 adding controller in, 141–147 Info.plist fi le, 76–77, 91 Attributes window, 65–66 Information Property list, 95–96 building Web browser, 283–287 inheritance, 364 Design window, 68–70 init method, 129, 364 Inspector window, 71–73 initFileURLWithPath method, 281 launching, 64 initWithContentsOfFile method, 298 Library window, 70–71 insertObject method, 195 Menu editor, 74–77 Inspector window overview, 13–15, 63 functions, 66 Project window, 66–68 launching, 66, 71–73 setting up bindings in, 335–340 opening, 23 testing browser in, 286 resizing window with, 24–25 windows, 65 instance. See objects Interface Builder Kit, 70 instance variables interface controls declaring, 111–112 adding, 26–28 overview, 110 bevel buttons, 174–175 378 Cocoa Programming for Mac OS X For Dummies

interface controls (continued) Media tab, 25 buttons, 167–173 Objects tab, 25 check box, 173–174 overview, 65–66 overview, 167 lightGrayColor, 224 progress indicator, 182–183 List view (Project window) push buttons, 169–171 loadResourceDataNotifyingClient radio control, 175–177 method, 282 round buttons, 171–173 loadWebPage action, 280 slider control, 178–179 longValue method, 192 tab view, 179–182 table, 184–189 interface fi les, 36, 111, 114 • M • Internet Mac OS Extended format, 102 downloading fi les, 281–283 Mac OS X, 7–8 loading Web page in browser, 280–281 magentaColor, 224 overview, 279 MainMenu item, 68 InternetController class MainMenu.xib adding code, 294 building interface with, 23–25 connecting to interface, 292–293 creating window in, 153 creating, 292 opening, 64 creating fi les for, 293 overview, 22–23 intValue method, 192 makeKeyAndOrderFront method, 151 iPhoto, 157 matrix, 175–177 isVisible method, 151 Media tab, 25 memory management, 117–119 Menu editor • J • functions, 66 JPEG fi les, 313 launching, 66 overview, 65–66 preparing menu for application, 74–77 • K • menu item, creating, 80–81 Key Equiv. fi eld, 72–73, 80, 170 Message Framework, 290 keyboard shortcuts, 361–362 messages, sending, 37, 115 KVC (Key-Value Coding), 333–334 methods, 110, 112–113. See also specifi c KVO (Key-Value Observing), 333–334 methods by name minimizing windows, 165–166 minutes, 197 • L • modal window, 215 Label control, 27, 335 model, 134 launchedApplications, 185 Model-View-Controller (MVC) design Layout settings (Xcode), 44 pattern Library window adding controller, 141–147 buttons, 168–169 adding view, 139–140 controls, 70–71 bindings, 330 function, 66 building project with, 135–139 launching, 25 controller, 134 model, 134 Index 379

overview, 133 creating fi les for, 124–125 real-world analogy, 134–135 naming, 121 view, 134 wiring interface to, 124 month name, 197 wiring interface to instance, 124 .mov fi le, 306 MyDataController class moveTheFile action, 263 adding outlets to, 185–186 movie player (Cocoa project) connecting data source, 187 adding actions to, 311 connecting to interface, 187 adding code, 311–312 creating, 185 adding outlets to, 311 creating fi les for, 187 adding QTMovieView control, 310 implementation fi les, 187–188 connecting MyMovieController to MyDocument class, 319–321 interface, 311 MyMovieController class creating, 310–312 adding actions to, 311 creating controller class, 310 adding code, 311–312 creating interface, 310 adding outlets to, 311 movies connecting to interface, 311 classes, 305–306 creating, 311 overview, 304–305 MyPrintController class player, 310–312 adding actions to, 271 QTMovieView class, 307–310 adding outlets to, 271 QuickTime, 313–314 adding printToPDF action to, 275–278 MP3 fi les, 313 changing header fi le, 272–273 .mp4 fi le, 306 changing implementation fi le, 273 MPEG-1 fi les, 313 connecting to interface, 271–272 multimedia creating, 270 building audio player, 299–305 creating fi les for, 272 building movie player, 310–312 MySheetController class loading sound fi les, 297–298 adding actions to, 162 playing sound fi les, 297–298 adding outlets to, 162 playing system sounds, 296–297 changing implementation fi le, 164–165 QTMovie, 306 connecting outlets and actions, 162–163 QTMovieView, 307–310 creating, 162 mutable arrays, 194–195 creating fi les for, 163 mutable object, 240 MyTextController class MVC design pattern. See Model-View- adding actions to, 205 Controller design pattern adding code, 206–208 My Application, 90 adding outlets to, 204 MyAudioController class creating, 204 adding code, 301–302 fi le formats, 213–214 adding stop functionality, 302–303 naming, 204 connecting actions to interface, 304–305 wiring interface to, 205–206 creating, 300 myTextView outlet, 322 MyClass class, 111 MyWindowController class MyController class adding actions to, 153–154 adding actions to, 122 adding code to application, 154–155 adding outlets to, 122 adding outlets to, 153–154 creating, 120 naming, 153 380 Cocoa Programming for Mac OS X For Dummies

NSOpenPanel class, 218, 298 • N • NSPageLayout class, 268, 273 name of application, 90, 93–94 NSPoint structure, 221–222, 237, 243 name variable, 118 NSRange parameter, 219 named color space, 225 NSRect structure, 222–223 New Application menu, 74 NSRunAlertPanel function, 265 New File window, 136 NSScaleToFit, 259 New File Wizard, 29 NSScrollView, 187 New Project window, 20–21, 136 NSSlider control, 178–179 NeXT operating system, 65 NSSound class, 296–297 NIB (NeXT Interface Builder), 65. See also NSString class, 118, 129, 196 NIB project window NSTableView control, 184 NIB project window NSTabView control, 181 Column view, 67–68 NSTabViewItem control, 181 functions, 66 NSTextField control, 201, 249–250, 280, Icon view, 66–67 335, 364–365 items, 68 NSTextView control, 201, 202–204, launching, 66 322–323, 364–365 List view, 67 NSURL class, 280 overview, 65–66 NSView class, 267 NSAlertDefaultReturn, 265 NSWindow class, 255 NSApplicationName, 185 NSWorkspace, 185, 280 NSArray class, 191, 193–194 numberOfRowsInTableView method, 188 NSButton control, 168–169, 203, 212, numbers, 191–192 249–250 numberWithDouble method, 192 NSCalendarDate class, 196 numberWithFloat method, 192 NSCancelButton, 256 numberWithInt method, 192 NSColor object, 223, 225 numberWithLong method, 192 NSColorwell control, 203 numberWithUnsignedShort method, 192 NSControl, 179 NSData control, 219 • O • NSDictionary, 240–242 NSFileManager method, 256–258 Objective-C language NSFileWrapper, 258 coding in, 115–119 NSHomeDirectory function, 262 creating classes, 29, 119–125 NSImage object, 243 declaring instance variables, 111–112 NSIndicator, 182–183 declaring methods, 112–113 NSLayout class, 268 defi ning methods, 114 NSLog, 181 instantiating objects, 117 NSMailDelivery class, 291 managing memory, 117–119 NSMakePoint function, 222 methods, 110 NSMatrix, 175–177 naming in, 130 NSMutableArray class, 194–195 objects, 110 NSMutableDictionary, 240–241 overview, 9, 109 NSNumber class, 191–192 passing parameters, 115–116 NSNumberFormatter class, 55–56 returning values, 116 NSObject class, 48, 111, 292 sending messages to objects, 115 NSOKButton, 216, 256 Index 381 object-oriented programming (OOP), 9, 109–110 • P • objects Page panel, 268–269 autoreleased, 119 pageData, 281 column view, 66 panel, adding to project, 160–165 dragging to interface, 34–35 parameters, passing, 115–116 icon view, 66 parent, 159 immutable, 240 partitions, 103 instance variables, 110 pasteboard, 210–211 instantiating, 117 paths list view, 66 Beziér, 230–231 methods, 110 defi ned, 248 mutable, 240 displaying, 256–258 sending messages to, 37, 115 drawing, 234–236 viewing in Library window, 70–71 fi lling, 231–234 Objects tab, 25 relative points, 238–239 objectValueForTableColumn stop-sign-shaped, 237–239 method, 188 stroking, 234–235 Omni Group, 369 PDF (Portable Document File), one-key access, 72–73 printing to, 275–278 online resources PDFKit, 71 Apple Developer Connection, 368 Photoshop, 98, 225 Apple Forums, 370 Pimp My Code series (blog), 369 Bookware Quickie, 368 Pixelmator, 98 Call Me Fishmeal, 369 plain text, 213 Cocoa Dev Central, 370 playAppSound action, 301 Cocoa Is My Girlfriend, 368 playSoundFile action, 301 CocoaDev, 370 playSystemSound action, 301 Dan Wood: Eponymous Weblog, 370 PNG fi les, 98, 313 Domain of the Bored, 369 points, 221–222 overview, 367 pop-up menu, 78–79 Theocacao, 369 Portable Document File (PDF), OOP (object-oriented programming), printing to, 275–278 9, 109–110 positioning windows, 151–152 Open Scripting Kit, 71 PostScript, 222 opening window, 150 preferences, customizing, 43–45 OpenPanel class, 254–256 prefsCheckbox, 173 openSheet method, 165 PrintInfo object, 268–269 openURL method, 280–281 printing operationPopup outlet, 81–82 classes, 267–268 orangeColor, 224 overview, 267–268 orderOut method, 151 page settings, 268–269 Other Sources group folder, 47 to PDF, 275–278 outlets steps in, 268–269 adding, 30, 122, 252–253 printOnepage method, 271, 274–275 connecting to interface, 81–83 printOperationWithView method, 275 connections, 33–35 Product Name key value, 94 382 Cocoa Programming for Mac OS X For Dummies

programming tips project, calculator Class Browser, 363 adding actions, 31 coordinate system, 365 adding breakpoints, 52–53 documentation, built-in, 362–363 adding class to interface, 31–33 drag and drop, 363–364 adding code to application, 36–37 init method, 364 adding controls to interface, 26–28 Interface Builder guidelines, 365–366 adding menu, 80–81 keyboard shortcuts, 361–362 adding outlets to class, 30 superclass, 364–365 adding pop-up menu, 78–79 window count, 363 application template, 21 progress indicators, 182–183 building, 37–39 project, audio player building interface, 23–25 adding stop functionality, 302–303 changing codes in, 45–48 attributes, 299 connecting class to interface, 33–35 buttons, 299 connecting interface, 81–83 connecting actions to interface, 304–305 creating classes, 29–30 interface, 299 creating Controller class, 81 MyAudioController class, 300–302 creating project, 20–21 project, Bank Account debugging, 37–39, 51–58 adding codes, 138–139 fi le comments, 49 adding controller, 141–147 fi xing codes, 55–57 adding labels, 140 idea for, 19–20 adding view, 139–140 naming project, 21–22 creating new class, 136–137 removing breakpoints, 57–58 implementation fi le, 139 selecting location for, 22 naming, 136–137 text fi elds, 27 naming new class, 138 title of application, 23–24 selecting application, 136 wiring interface, 29–33 setting up bindings, 335–340 project, Core Data title of application, 140 assigning relationships, 351–353 project, book application building interface, 354–358 assigning relationships, 351–353 creating data model, 344–350 Author entity, 346–353 creating new project, 342 Book entity, 345–353 Models folder, 343 building interface, 354–358 naming, 342–343 Category entity, 346–353 templates, 342–343 creating data model, 344–350 project, movie player creating new project, 342 adding actions to, 311 isbn attribute, 347–348 adding code, 311–312 Models folder, 343 adding outlets to, 311 naming, 342–343 adding QTMovieView control, 310 pages attribute, 347 connecting MyMovieController to synopsis attribute, 347–348 interface, 311 templates, 342–343 creating, 310–312 title attribute, 346–347 creating controller class, 310 creating interface, 310 Index 383 project, MVC design adding codes, 138–139 • Q • adding controller, 141–147 QTMedia class, 306 adding labels, 140 QTMovie class, 305, 306, 314 adding view, 139–140 QTMovieView class creating new class, 136–137 color attribute, 308 implementation fi le, 139 controller, 308 naming, 136–137 editable attribute, 308 naming new class, 138 overview, 307 selecting application, 136 volume attribute, 308–310 title of application, 140 QTTrack class, 305 Project window QTVR fi les, 313 Column view, 67–68 Quartz Composer, 71 functions, 66 Quartz graphics engine, 221–222 Icon view, 66–67 Quick Model, 48 items, 68 QuickTime, 313–314 launching, 66 QuickTime Kit, 71 List view, 67 Quit NewApplication menu, 74 overview, 65–66 projects. See also projects with bindings; specifi c project entries • R • adding comments to, 49 radio control, 175–177 adding e-mail functions to, 291–294 readFromData method, 327 adding panel to, 160–165 rectangles, 222–223 assigning icons to, 97 redColor, 224 bindings, 331–332 reference counting, 117 changing codes in, 46–47 relative points, 237 creating, 20–21 release message, 117 debugging, 51–58 removeFileAtPath method, 264–265 naming, 21–22 removeObjectAtIndex method, 195 selecting location for, 22 replaceCharactersInRange projects with bindings method, 219 implementing, 334–340 replaceObjectAtIndex method, 195 key-value coding, 333–334 resizing window, 24–25 key-value observing, 333–334 resourceDataUsingCache method, overview, 329 281–282 setting up in Interface Builder, 335–340 resources, online starting project with, 331–332 Apple Developer Connection, 368 property, 344–346 Apple Forums, 370 Property List editor, 91 Bookware Quickie, 368 purpleColor, 224 Call Me Fishmeal, 369 Push Button control, 26 Cocoa Dev Central, 370 push buttons, 169–171 Cocoa Is My Girlfriend, 368 CocoaDev, 370 384 Cocoa Programming for Mac OS X For Dummies

resources, online (continued) setTextColor action, 205, 207 Dan Wood: Eponymous Weblog, 370 setTitle method, 157, 255 Domain of the Bored, 369 SetTitleWithRepresentedFileName overview, 367 method, 158 Theocacao, 369 sharedWorkspace class, 280 retain method, 119 sheet, 159–165 retrieving text, 216–219 Show controller attribute, 308 Return key, 72–73 showing window, 150–151 reusable codes, 9, 366 showPagePanel method, 271, 273 RGB color space, 225 slider control, 178–179 rich text, 96, 213 Sound fi eld, 171 round buttons, 171–173 sound fi les, 170–171 rounded level button, 174–175 soundUnfilteredFileTypes class, 298 RTFFromRange method, 216 source code fi les, 36 runModal method, 215, 256 square bevel button, 174–175 runModalWithPrintInfo method, 273 startAnimation method, 183 runOperation method, 275 status 0 message, 44–45 runtime errors, 51 stopAnimation method, 183 stop-sign-shaped path, creating, 237–239 stopSoundFile action, 302–305 • S • stringByExpandingTildeInPath Save As dialog, 21 method, 282 SavePanel, 215 Strings window, 65 seconds, 197 stringWithString method, 119 selectedRow method, 177 stroke function, 235 selectedTag message, 84 superclass, 48, 364–365 selectTheFile action, 259, 262 syntax error, 51, 57 sendEMailManually action, 292 system sounds, playing, 296–297 sendEMailWithClient action, 292 setAlpha method, 158 setBackgroundColor action, 205, 207 • T • SetBalance method, 334–340 tab view, 179–182 setCanChooseDirectories method, 255 table control, 184–189 setDoubleValue method, 183 TabViewItem, 181 setExcludeFromWindowsMenu Tag property, 79 method, 152 takeURLStringFrom message, 285 setFirstName method, 128 Targets folder, 93 setFloatValue method, 59, 179 Terminal, 248 setFormat message, 55 text setFormatter method, 59 adding code, 206–208 SetFrame method, 157 adding style, 208–210 setFrameOrigin method, 151–152 building interface, 202–204 setIntValue method, 179 controller class, 204–205 setLineWidth function, 235 controls, 201 setName method, 118–119 drawing, 239–242 setReleasedWhenClosed method, 150 manipulating, 210–213 setStringValue method, 256–258 manual editing, 211–213 setter method, 118 pasteboard manipulations, 210–211 Index 385

plain, 213 Web Kit, 70 retrieving, 216–219 Web page, loading, 280–281 rich, 213 Web sites for developers saving, 213–216 Apple Developer Connection, 368 style functions, 208–209 Apple Forums, 370 wiring interface, 205–206 Bookware Quickie, 368 text fi elds, 27, 285 Call Me Fishmeal, 369 textColorwell outlet, 204 Cocoa Dev Central, 370 Textured check box, 155–156 Cocoa Is My Girlfriend, 368 textView outlet, 204 CocoaDev, 370 Theocacao (blog), 369 Dan Wood: Eponymous Weblog, 370 theURLField outlet, 280 Domain of the Bored, 369 TIFF fi les, 313 overview, 367 title of application, 90, 93–94 Theocacao, 369 Title property, 23 WebKit Framework, 283–284 toggleRuler action, 205 WebView control tracking windows, 152 connecting buttons to, 286 connecting text fi eld control to, 285 weekday name, 197 • U • whiteColor, 224 unsignedShort method, 192 Window Attributes, 23 URL (Universal Resource Locator), 280 window count, 363 URLResourceDidFinishLoading Window item, 68 method, 282 windowControllerDidLoadNib URLWithString parameter, 281–283 method, 327 UTF8, 216 windowDidMiniaturize method, 166 windows adding buttons, 153 • V • changing appearance of, 155–157 Value of the Copyright (Human-Readable) closing, 150 key, 95 creating, 153–155 valueForKey method, 333 events, 165–166 valueForKeyPath method, 188 hiding, 150–151 values, returning, 116 keep track of, 152 version number, 90, 94–95 minimizing, 165–166 view, 134, 139 modal, 216 Volume attribute, 308–310 opening, 150 overview, 149 positioning, 151–152 • W • resizing, 24–25, 157 setting title, 157 Web browser setting transparency, 158 building, 283–287 sheet, 159–165 buttons, 286 showing, 150–151 functions, 283 textured property, 155–157 interface, 285 withAttributes parameter loading Web page, 280–281 text fi eld control, 285 386 Cocoa Programming for Mac OS X For Dummies

Workspace Guide (Xcode), 58 working with favorites, 50 writeToFile method, 215, 278, 281 working with project fi les, 45–47 WYSIWYG interface, 14 Workspace Guide, 58 Xcode Developer Tools advantages of, 8 • X • downloading, 7–8 Xcode XIB fi les, 65 adding outlets to class, 31 XML (Extensible Markup Language), 91 building applications, 60–61 changing codes in projects, 45–47 Class models, 48 • Y • creating classes, 31 year, 197 customizing preferences, 43–45 yellowColor, 224 fi le comments, 49 Help feature, 58–59 launching, 20 • Z • layout settings, 43–44 Zarra, Marcus, 368 overview, 10–12, 42 zoom method, 157 QuickModel, 48 using interface in, 83–87