PrintNumber | ErrorLocation | Error | Correction | DateAdded |
---|---|---|---|---|
1 | pii | remove Programming in Objective-C Stephen G. Kochan ISBN-13: 978-0-321-56615-7 |
fixed | 1/29/2009 |
1 | piv | First Printing December 2008 | Second Printing, January 2009 | 1/29/2009 |
1 | piv | Sams Publishing cannot attest to the accuracy of this information. | Pearson cannot attest to the accuracy of this information. | 1/29/2009 |
1 | pxvi | About the Technical Reviewers | About the Technical Reviewer | 1/29/2009 |
1 | pxvii | Mark Taub Associate Publisher Sams Publishing |
Mark Taber Associate Publisher Pearson Education |
1/29/2009 |
1 | pxvii | Visit our website and register this book at www.informit.com/title/9780321566157 for convenient access to any updates, downloads, or errata that might be available for this book. | Visit our website and register this book at www.informit.com/register for convenient access to any updates, downloads, or errata that might be available for this book. | 1/29/2009 |
1 | p1 | This software is in the public domain, which means that anyone who wants to learn how to program in Objective-C can do so by downloading its tools at no charge. | The copyrights for all Free Software Foundation (FSF) products are owned by the FSF. It is released under the GNU General Public License. | 1/29/2009 |
1 | p9 | #import Foundation/Foundation.h> | #import <Foundation/Foundation.h> | 1/29/2009 |
1 | p14 | // First program example int main (int argc, const char * argv[]) |
// First program example #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) |
1/29/2009 |
1 | p18 | // First program example int main (int argc, const char * argv[]) |
// First program example #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) |
1/29/2009 |
1 | p50 | See Table B.2 in Appendix B, Objective-C Language Summary, for more information about data type sizes. | See Table B.3 in Appendix B, Objective-C Language Summary, for more information about data type sizes. | 1/29/2009 |
1 | p51 | The value 1.7e4 is a floating-point value expressed in this notation that represents the value 1.7 x 10-4. | The value 1.7e4 is a floating-point value expressed in this notation that represents the value 1.7 x 104. | 1/29/2009 |
1 | p163 | NSLog ( w = %i, h = %i", | NSLog (@"Rectangle: w = %i, h = %i", | 1/29/2009 |
1 | p180 | -(id) dealloc { if (origin) [origin release]; return [super dealloc]; } |
-(void) dealloc { if (origin) [origin release]; [super dealloc]; } |
1/29/2009 |
1 | p180 | The dealloc method is defined to return a value of type id. You know this by looking inside the header file <NSObject.h> where it is declared. | The dealloc method is defined to not return a value. | 1/29/2009 |
1 | p180 | -(id) dealloc { [origin release]; return [super dealloc]; } |
-(void) dealloc { [origin release]; [super dealloc]; } |
1/29/2009 |
1 | p203 | Add Note after Exercise 4. You'll have to change the name of the methods to something other than add:. Thats because the systems NSObjectController class also has an add: method. As noted on the top of page 195, if multiple methods of the same name exist in different classes and the type of the receiver isnt known at compile time, the compiler will perform a consistency check to make sure the arguments and return types are consistent among the similarly named methods. |
fixed | 1/29/2009 |
1 | p204 | Delete Exercise 6. |
fixed | 1/29/2009 |
1 | p219 | typedef enum _NSComparisonResult { NSOrderedAscending = -1, NSOrderedSame, NSOrderedDescending } NSComparisonResult |
enum _NSComparisonResult { NSOrderedAscending = -1, NSOrderedSame, NSOrderedDescending }; typedef NSInteger NSComparisonResult; |
1/29/2009 |
1 | p237 | @interface Square: Object { Rectangle *rect; } -(Square*) initWithSide: (int) s; -(void) setSide: (int) s; -(int) side; -(int) area; -(int) perimeter; -(id) dealloc; // Override to release the Rectangle objects memory @end |
@interface Square: NSObject { Rectangle *rect; } -(Square*) initWithSide: (int) s; -(void) setSide: (int) s; -(int) side; -(int) area; -(int) perimeter; -(void) dealloc; // Override to release the Rectangle objects memory @end |
1/29/2009 |
1 | p360 | -(BOOL) isEqual (AddressCard *) theCard | -(BOOL) isEqual: (AddressCard *) theCard | 1/29/2009 |
1 | p480 | Program 21.2 code missing last line, @end. | fixed | 1/29/2009 |
1 | p480 | Program 21.2 Fraction_CalculatorViewController.m Interface File | Program 21.2 Fraction_CalculatorViewController.h Interface File | 1/29/2009 |
1 | p481 | #import Fraction_CalculatorAppDelegate.h @implementation Fraction_CalculatorAppDelegate @synthesize window, displayString, display; - (void)applicationDidFinishLaunching:(UIApplication *)application { |
#import "Fraction_CalculatorViewController.h" @implementation Fraction_CalculatorViewController @synthesize display, displayString; -(void) viewDidLoad { |
1/29/2009 |
1 | p482 | delete line: [window makeKeyAndVisible]; |
fixed | 1/29/2009 |
1 | p484 | delete line: [window release]; |
fixed | 1/29/2009 |
1 | p514 | Integer value; that is, a value that contains no decimal point; guaranteed to contain at least 16 bits of accuracy | Integer value; that is, a value that contains no decimal point; guaranteed to contain at least 32 bits of accuracy | 1/30/2009 |
1 | p514 | Positive integer value; can store positive values up to twice as large as an int; guaranteed to contain at least 16 bits of accuracy | Positive integer value; can store positive values up to twice as large as an int; guaranteed to contain at least 32 bits of accuracy | 1/30/2009 |
1 | p28 | For example, washing you car applies to an instance (in fact, all the methods listed in Table 3.1 can be considered instance methods). | For example, washing your car applies to an instance (in fact, all the methods listed in Table 3.1 can be considered instance methods). | 1/30/2009 |
1 | p82 | NSLog (@TABLE OF TRIANGULAR NUMBERS); NSLog (@ n Sum from 1 to n); NSLog (@-- --------); |
NSLog (@TABLE OF TRIANGULAR NUMBERS); NSLog (@ n Sum from 1 to n); NSLog (@-- --------); |
1/30/2009 |
1 | p130 | -50.000000 | = -50.000000 | 1/30/2009 |
1 | p156 | 1. Add the following methods to the Fraction class to round out the arithmetic operations on fractions. Reduce the result within the method in each case: // Subtract argument from receiver (Fraction *) subtract (Fraction *) f; // Multiply receiver by argument (Fraction *) multiply (Fraction *) f; // Divide receiver by argument (Fraction *) divide (Fraction *) f; |
1. Add the following methods to the Fraction class to round out the arithmetic operations on fractions. Reduce the result within the method in each case: // Subtract argument from receiver (Fraction *) subtract: (Fraction *) f; // Multiply receiver by argument (Fraction *) multiply: (Fraction *) f; // Divide receiver by argument (Fraction *) divide: (Fraction *) f; |
1/30/2009 |
1 | p156 | 3. Modify Program 7.7 to also display the resulting sum as a fraction, not just as a real number. | 3. Modify Program 7.6 to also display the resulting sum as a fraction, not just as a real number. | 1/30/2009 |
1 | p156 | 6. Exercise 7 in Chapter 4, Data Types and Expressions, defined a new class called Complex for working with complex imaginary numbers. Add a new method called add: that can be used to add two complex numbers. To add two complex numbers, you simply add the real parts and the imaginary parts, as shown here: (5.3 + 7i) + (2.7 + 4i) = 8 + 11i Have the add: method store and return the result as a new Complex number, based on the following method declaration: -(Complex *) add: (Complex * complexNum); Make sure you address any potential memory leakage issues in your test program. |
6. Exercise 6 in Chapter 4, Data Types and Expressions, defined a new class called Complex for working with complex imaginary numbers. Add a new method called add: that can be used to add two complex numbers. To add two complex numbers, you simply add the real parts and the imaginary parts, as shown here: (5.3 + 7i) + (2.7 + 4i) = 8 + 11i Have the add: method store and return the result as a new Complex number, based on the following method declaration: -(Complex *) add: (Complex *) complexNum; Make sure you address any potential memory leakage issues in your test program. |
1/30/2009 |
1 | p156 | 7. Given the Complex class developed in exercise 7 of Chapter 4 and the extension made in exercise 6 of this chapter, create separate Complex.h and Complex.m interface and implementation files. | 7. Given the Complex class developed in exercise 6 of Chapter 4 and the extension made in exercise 6 of this chapter, create separate Complex.h and Complex.m interface and implementation files. | 1/30/2009 |
1 | p161 | then ClassC would inherit all of ClassBs methods and instance variables, which in turn inherited all of ClassAs methods and instance variables, which in turn inherited all of Objects methods and instance variables. Be sure you understand that each instance of a class gets it own instance variables, even if theyre inherited. |
then ClassC would inherit all of ClassBs methods and instance variables, which in turn inherited all of ClassAs methods and instance variables, which in turn inherited all of NSObjects methods and instance variables. Be sure you understand that each instance of a class gets its own instance variables, even if theyre inherited. |
1/30/2009 |
1 | p163 | NSLog ( w = %i, h = %i, | NSLog ( @rectangle: w = %i, h = %i, | 1/30/2009 |
1 | p163 | The first printf call verifies this. | The first line of output verifies this. | 1/30/2009 |
1 | p167 | To illustrate an important point, were wont synthesize the accessor methods for the origin now. | To illustrate an important point, we wont synthesize the accessor methods for the origin now. | 1/30/2009 |
1 | p168 | Program 8.4 XPoint.h Interface File |
Program 8.4 XYPoint.h Interface File |
1/30/2009 |
1 | p170 | (void) setOrigin: (Point *) pt | (void) setOrigin: (XYPoint *) pt | 1/30/2009 |
1 | p171 | The three printf calls then retrieve and print the values. | The three NSLog calls then retrieve and print the values. | 1/30/2009 |
1 | p177 | Figure 8.9 error: Class Object should be NSObject | fixed | 1/30/2009 |
1 | p184 | Identify the hierarchical relationship between the Object class, ClassA, ClassB, and ClassB2. | Identify the hierarchical relationship between the NSObject class, ClassA, ClassB, and ClassB2. | 1/30/2009 |
1 | p192 | The Fraction f1 is set to 2/5, and the Complex number c2 is set to (10 + 2.5i). | The Fraction f1 is set to 2/5, and the Complex number c1 is set to (10 + 2.5i). | 1/30/2009 |
1 | p290 | Fraction *fractsPtr | Fraction **fractsPtr | 1/30/2009 |
1 | p290 | [fractsPtr print] | [*fractsPtr print] | 1/30/2009 |
1 | p292 | result = [fractsPtr add: fractsPtr + 1] | result = [*fractsPtr add: *(fractsPtr + 1)]; | 1/30/2009 |
1 | p74 | 5. (3.31 x 10-8 x + 2.01 x 10-7) / (7.16 x 10-6 + 2.01 x 10-8) | (3.31 x 10-8 + 2.01 x 10-7) / (7.16 x 10-6 + 2.01 x 10-8) | 2/4/2009 |
1 | p139 | delete: -(void) setTo: (int) n over: (int) d; |
fixed | 2/4/2009 |
1 | p139 | 7. delete: NSString *format = x = %i; |
fixed | 2/4/2009 |
1 | p334 | // Create immutable string from nonmutable | // Create mutable string from nonmutable | 2/4/2009 |
1 | p337 | The remaining lines in the program example show how to perform a search and replace. First, you locate the string @This is inside the string mstr, which contains | The remaining lines in the program example show how to perform search and replace operations. In the first case, you locate the string @This is inside the string mstr, which has been set to @This is a mutable string. This string is found inside the search string and gets replaced by the string @An example of. The net result is that mstr gets changed to the string @An example of a mutable string. | 2/4/2009 |
1 | p337 | The search string is set to @a and the replacement string is set to | The search string is set to @a and the replacement string is set to @X. | 2/4/2009 |
1 | p342 | You can use the class method arrayWithObjects: can be to create an array with a list of objects as its elements. | You can use the class method arrayWithObjects: to create an array with a list of objects as its elements. | 2/4/2009 |
1 | p342 | Each retrieved element is converted to a C string and then displayed with printf. | Each retrieved element is displayed with NSLog. | 2/4/2009 |
1 | p5 | I am extremely grateful to Michael de Haan and Wendy Mui for doing an incredible, unsolicited job proofreading this second edition. Their meticulous attention to detail has resulted in a list of both typographical and substantive errors that have been addressed in the second printing. Publishers take note: these two pairs of eyes are priceless! |
added text. | 2/13/2009 |
1 | p51 | For example, 0x0.3p10 represents the value 3/16 X 210 = 0.5. | For example, 0x0.3p10 represents the value 3/16 X 210 = 192. | 2/13/2009 |
1 | p105 | The number is even displays. | The number is even. displays. | 2/13/2009 |
1 | p212 | The static declaration of counter makes it accessible to any method defined in the implementation section, yet it does not make it accessible from outside the file. | The static declaration of gCounter makes it accessible to any method defined in the implementation section, yet it does not make it accessible from outside the file. | 2/13/2009 |
1 | p213 | When the program begins execution, the value of counter is automatically set to 0 (recall that you can override the inherited class initialize method if you want to perform any special initialization of the class as a whole, such as set the value of other static variables to some nonzero values). | When the program begins execution, the value of gCounter is automatically set to 0 (recall that you can override the inherited class initialize method if you want to perform any special initialization of the class as a whole, such as set the value of other static variables to some nonzero values). | 2/13/2009 |
1 | p222 | On some machines (such as on on the Intel processors used in the current Macintosh line of computers as well as on the ARM processors currenly used in the iPhone and iTouch), characters are treated as signed quantities. | On some machines (such as on the Intel processors used in the current Macintosh line of computers as well as on the ARM processors currently used in the iPhone and iTouch), characters are treated as signed quantities. | 2/13/2009 |
1 | p226 | After @interface Fraction : NSObject add: { int numerator; int denominator; } |
fixed | 2/13/2009 |
1 | p235 | The previously-described @optional directive that was added the Objective C 2.0 language is meant to replace the use of informal protocols. | The previously-described @optional directive that was added to the Objective-C 2.0 language is meant to replace the use of informal protocols. | 2/13/2009 |
1 | p235 | Youve learned several ways to extend the definition of a class through techniques such as subclassing, using categories, and posing. | Youve learned several ways to extend the definition of a class through techniques such as subclassing and using categories. | 2/13/2009 |
1 | p244 | assigns the value of v2 to y. Think about would happen in the case of the following statement: | assigns the value of v2 to y. Think about what would happen in the case of the following statement: | 2/13/2009 |
1 | p318 | You should also take advantage of the Foundation framework documentation that is stored on your system (buried deep in the /Develop/Documentation directory) and that is also available online at Apples website. | You should also take advantage of the Foundation framework documentation that is stored on your system (buried deep in the /Developer/Documentation directory) and that is also available online at Apples website. | 2/13/2009 |
1 | p331 | // Extract first 4 chars from string res = [str1 substringToIndex: 3]; NSLog (@First 3 chars of str1: %@, res); // Extract chars to end of string starting at index 6 |
// Extract first 3 chars from string res = [str1 substringToIndex: 3]; NSLog (@First 3 chars of str1: %@, res); // Extract chars to end of string starting at index 5 |
2/16/2009 |
1 | p333 | str1 = [str1 stringFromIndex: 5]; | str1 = [str1 substringFromIndex: 5]; | 2/16/2009 |
1 | p337 | Finally, the NSString class also contains a method called replaceOccurrencesOfString:withString:options:range: that you can use to do a search-and-replace-all on a string. | Finally, the NSMutableString class also contains a method called replaceOccurrencesOfString:withString:options:range: that you can use to do a search-and-replace-all on a string. | 2/16/2009 |
1 | p344 | You define kMaxPrime to the maximum prime number you want the program to calculate, which, in this case, is 50. | You define MAXPRIME to the maximum prime number you want the program to calculate, which, in this case, is 50. | 2/16/2009 |
1 | p344 | The program then enters a for loop to find prime numbers starting with 5, going up to kMaxPrime and skipping the even numbers in between (p += 2). | The program then enters a for loop to find prime numbers starting with 5, going up to MAXPRIME and skipping the even numbers in between (p += 2). | 2/16/2009 |
1 | p358 | NSLog (@Stephen Kochan); | NSLog (@Lookup: Stephen Kochan); | 2/16/2009 |
1 | p361 | NSLog (@Stephen Kochan); | NSLog (@Lookup: Stephen Kochan); | 2/16/2009 |
1 | p367 | NSLog (@%@, [glossary objectForKey: @adopt]); NSLog (@%@, [glossary objectForKey: @archiving]); |
NSLog (@adopt: %@, [glossary objectForKey: @adopt]); NSLog (@archiving: %@, [glossary objectForKey: @archiving]); |
2/16/2009 |
1 | p371 | @interface NSSet (Printing); -(void) print; @end @implementation NSSet (Printing); |
@interface NSSet (Printing) -(void) print; @end @implementation NSSet (Printing) |
2/16/2009 |
1 | p372 | if ([set1 isEqualToSet: set2] == NO) | if ([set1 isEqualToSet: set2] == YES) | 2/16/2009 |
1 | p378 | -(NSData *) createFileAtPath: path contents: (NSData *) data | -(BOOL) createFileAtPath: path contents: (BOOL) data | 2/16/2009 |
1 | p381 | NSLog(@%@ [NSString stringWithContentsOfFile: @newfile2]); | NSLog(@%@ [NSString stringWithContentsOfFile: @newfile2 encoding: NSUTF8StringEncoding error: nil]); |
2/16/2009 |
1 | p384 | Many of these methods are the same as are used for ordinary files, as listed in Table 16.1. | Many of these methods are the same as those for ordinary files, as listed in Table 16.1. | 2/16/2009 |
1 | p388 | NSLog (@Contents of %@:, path; | NSLog (@Contents of %@:, path); | 2/16/2009 |
1 | p389 | An NSDirectortyEnumerator object gets returned by the enumeratorAtPath: method, which is stored inside dirNum. | An NSDirectortyEnumerator object gets returned by the enumeratorAtPath: method, which is stored inside dirEnum. | 2/16/2009 |
1 | p389 | NSLog (%@, dirArray); | NSLog (@%@, dirArray); | 2/16/2009 |
1 | p391 | ~stevekochan/progs/../ch16/./path.m => ~stevekochan/ch16/path.m | ~stevekochan/progs/../ch16/./path.m => /Users/stevekochan/ch16/path.m | 2/16/2009 |
1 | p396 | Usage: copy from-file to-file | Usage: copy src dest | 2/16/2009 |
1 | p397 | So, if the value of source is the string ch16/copy1.m and the value of dest is /Users/stevekochan/progs and the latter is a directory, you change the value of dest to /Users/stevekochan/ progs/copy1.m. | So, if the value of source is the string ch16/copy1.m and the value of dest is /Users/stevekochan/progs and the latter is a directory, you change the value of dest to /Users/stevekochan/progs/copy1.m. | 2/16/2009 |
1 | p398 | -(void) seekToEndOfFile | -(unsigned long long) seekToEndOfFile | 2/16/2009 |
1 | p399 | NSLog(@%@, [NSString StringWithContentOfFile: @testout]); | -(unsigned long long) seekToEndOfFile | 2/16/2009 |
1 | p419 | after poolrelease = 1 | after pool drain = 1 | 2/16/2009 |
1 | p420 | The system automatically keeps tracks of what objects own what other objects, automatically freeing up (or garbage-collecting) objects that are no longer referenced as space is needed during the programs execution. | The system automatically keeps track of what objects own what other objects, automatically freeing up (or garbage-collecting) objects that are no longer referenced as space is needed during the programs execution. | 2/16/2009 |
1 | p422 | Return to the Fraction class you worked with throughout Part I, The Objective-C Language. | Return to the Fraction class you worked with throughout Part I, The Objective-C 2.0 Language. | 2/16/2009 |
1 | p427 | You retrieved the first element of dataArray2 with the following statement: mStr = [dataArray2 objectAtIndex: 0];d |
You retrieved the first element of dataArray with the following statement: mStr = [dataArray objectAtIndex: 0];d |
2/16/2009 |
1 | p434 | 2. Modify the Rectangle and XYoint classes defined in Chapter 8 to conform to the <NSCopying> protocol. | 2. Modify the Rectangle and XYPoint classes defined in Chapter 8 to conform to the <NSCopying> protocol. | 2/16/2009 |
1 | p436 | if ([glossary writeToFile: @glossary atomically: YES] == NO) | if ([glossary writeToFile: @glossary atomically: YES encoding: NSUTF8Encoding error: nil] == NO) |
2/16/2009 |
1 | p436 | The writeToFile:atomically: message is sent to your dictionary object glossary, causing the dictionary to be written to the file glossary in the form of a property list. | The writeToFile:atomically:encoding:error: message is sent to your dictionary object glossary, causing the dictionary to be written to the file glossary in the form of a property list. | 2/16/2009 |
1 | p442 | Each instance variable is then decoded by invoking the decodeObject:forKey: method and passing the same key that was used to encode the variable. | Each instance variable is then decoded by invoking the decodeObject:ForKey: method and passing the same key that was used to encode the variable. | 2/16/2009 |
1 | p448 | // Write the archived data are to a file if ( [dataArea writeToFile: @myArchive atomically: YES] == NO) |
// Write the archived data area to a file if ([dataArea writeToFile: @myArchive atomically: YES encoding: NSUTF8Encoding error: nil] == NO) |
2/16/2009 |
1 | p448 | You can use encodeObject: for these objects because you previously implemented encoder and decoder methods for the AddressBook, AddressCard, and Foo classes. | You can use encodeObject:forKey: for these objects because you previously implemented encoder and decoder methods for the AddressBook, AddressCard, and Foo classes. | 2/16/2009 |
1 | p449 | The message expression [data writeToFile: @myArchive atomically: YES] sends the writeToFile:atomically: message to your data stream to ask it to write its data to the specified file, which you named myArchive. As you can see from the if statement, the writeToFile:atomically: method returns a BOOL value: YES if the write operation succeeds and NO if it fails (perhaps an invalid pathname for the file was specified or the file system is full). |
The message expression [dataArea writeToFile: @myArchive atomically: YES encoding: NSUTF8Encoding error: nil] sends the writeToFile:atomically:encoding:error: message to your data stream to ask it to write its data to the specified file, which you named myArchive. As you can see from the if statement, the writeToFile:atomically:encoding:error: method returns a BOOL value: YES if the write operation succeeds and NO if it fails (perhaps an invalid pathname for the file was specified or the file system is full). |
2/16/2009 |
1 | p450 | In Program 19.2, you tried to make a copy of an array containing mutable string elements and you saw how a shallow copy of the array was made. | In Program 18.2, you tried to make a copy of an array containing mutable string elements and you saw how a shallow copy of the array was made. | 2/16/2009 |
1 | p452 | 1. In Chapter 15, Program 15.8 generated a table of prime numbers. | 1. In Chapter 15, Program 15.7 generated a table of prime numbers. | 2/16/2009 |
4 | p 17 | Well call the program prog1; here, then, is the command line to compile your first Objective-C program: $ gcc framework Foundation prog1.m -o prog1 Compile prog1.m & call it prog1 $ |
Well call the program prog1; here, then, is the command line to compile your first Objective-C program: $ gcc framework Foundation prog1.m -o prog1 Compile prog1.m & call it prog1 $ |
5/8/2009 |
4 | p 26 | 6. What output would you expect from the following program? #import <Foundation/Foundation.h> int main (int argc, const char *argv[])) { |
6. What output would you expect from the following program? #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { |
5/8/2009 |
4 | p 29 | [yourCar topDown]; if its a convertible [yourCar topUp]; currentMileage = [suesCar currentOdometer]; |
[yourCar topDown]; if its a convertible [yourCar topUp]; currentMileage = [yourCar currentOdometer]; |
5/8/2009 |
4 | p 38 | //---- @implementation section ---- @implementation Fraction (void) print { NSLog (%i/%i, numerator, denominator); } |
//---- @implementation section ---- @implementation Fraction (void) print { NSLog (@%i/%i, numerator, denominator); } |
5/8/2009 |
4 | p 50 | The format characters %x display a value in hexadecimal format without the leading 0x and using lowercase letters af for hexidecimal digits. To display the value with the leading 0x, you use the format characters %#x, as in the following: |
The format characters %x display a value in hexadecimal format without the leading 0x and using lowercase letters af for hexadecimal digits. To display the value with the leading 0x, you use the format characters %#x, as in the following: |
5/8/2009 |
4 | p 70 | w1 1010 0101 0010 1111 0xa52f ~w1 0101 1010 1101 0000 0x5ab0 |
w1 1010 0101 0010 1111 0xa52f ~w1 0101 1010 1101 0000 0x5ad0 |
5/8/2009 |
4 | p 71 | The fifth NSLog call illustrates DeMorgans rule: ~(~a & ~b) is equal to a | b, and ~(~a | ~b) is equal to a & b. The sequence of statements that follows next in the program verifies that the exchange operation works as discussed in the section on the exclusive-OR operator. |
The fifth NSLog call illustrates DeMorgans rule: ~(~a & ~b) is equal to a | b, and ~(~a | ~b) is equal to a & b. |
5/8/2009 |
4 | p 97 | 4. A minus sign placed in front of a field width specification causes the field to be displayed left-justified. Substitute the following NSLog statement for the corresponding statement in Program 5.2, run the program, and compare the outputs produced by both programs: |
4. A minus sign placed in front of a field width specification causes the field to be displayed left-justified. Substitute the following NSLog statement for the corresponding statement in Program 5.3, run the program, and compare the outputs produced by both programs: |
5/8/2009 |
4 | p 109 | Using blank spaces to set off the various operators still makes the previous expression readable. If you decided to ignore this and removed the unnecessary set of parentheses, you could end up with an expression that looked like this: if(year%4==0&&year%100!=0)||year%400==0) |
Using blank spaces to set off the various operators still makes the previous expression readable. If you decided to ignore this and removed the unnecessary set of parentheses, you could end up with an expression that looked like this: if(year%4==0&&year%100!=0||year%400==0) |
5/8/2009 |
4 | p 115 | Lets suppose for the next example that you want to write a program that allows the user to type in simple expressions of the following form:[[STYLE_FIRST]] |
Lets suppose for the next example that you want to write a program that allows the user to type in simple expressions of the following form: | 5/8/2009 |
4 | p 146 | Later in this chapter, youll redefine the add: method so that add: does not affect the value of its argument. |
Later in this chapter, youll redefine the add: method so that add: does not affect the value of its receiver. |
5/8/2009 |
4 | p 153 | [result setTo: numerator * f.denominator + denominator * f.numerator over: denominator * f.denominator; |
[result setTo: numerator * f.denominator + denominator * f.numerator over: denominator * f.denominator]; |
5/8/2009 |
4 | p 155 | -(void) print; -(double) convertToNum; -(Fraction *) add: (Fraction *) f; -(void) reduce; @end |
-(void) print; -(void) setTo: (int) n over: (int) d; -(double) convertToNum; -(Fraction *) add: (Fraction *) f; -(void) reduce; @end |
5/8/2009 |
4 | p 163 | Program 8.2 #import Rectangle.h #import <stdio.h> int main (int argc, char *argv[]) |
Program 8.2 #import Rectangle.h int main (int argc, char *argv[]) |
5/8/2009 |
4 | p 170 | (Point *) origin { return origin; } @end |
(XYPoint *) origin { return origin; } @end |
5/8/2009 |
4 | p 171 | NSLog (@Area = %i, Perimeter = %i, [myRect area], [myRect perimeter]); [myRect release]; [myPoint release]; |
NSLog (@Area = %i, Perimeter = %i, [myRect area], [myRect perimeter]); [myRect release]; [myPoint release]; |
5/8/2009 |
4 | p 176 | Program 8.6 Output x = 200 Clearly, the message [b initVar]; |
Program 8.6 Output x = 200 Clearly, the message [b initVar]; |
5/8/2009 |
4 | p 185 | Add note to end of page 185. | Note You should use printf to draw your characters, since NSLog will display a new line each time its called. |
5/8/2009 |
4 | p 188 | You should have completed the implementation section for this class in Exercise 6 from Chapter 4, Data Types and Expressions. | You should have completed the implementation section for this class in Exercises 6 and 7 from Chapter 7, More on Classes. | 5/11/2009 |
4 | p 191 | Well talk about that more in Chapter 18, Copying Objects. | Well talk about that more in Chapter 17, Memory Management. | 5/11/2009 |
4 | p 196 | Table 9.1 summarizes some of the basic methods that the Object class supports for asking these types of questions. | Table 9.1 summarizes some of the basic methods that the NSObject class supports for asking these types of questions. | 5/11/2009 |
4 | p 197 | To see if my Fraction class, you test the result from the expression, like this: | To see if the variable myFract is a Fraction class object, you test the result from the expression, like this: | 5/11/2009 |
4 | p 216 | Program 10.3 // print the number of days in a month int main (int argc, char *argv[]) |
Program 10.3 #import <Foundation/Foundation.h> // print the number of days in a month int main (int argc, char *argv[]) |
5/11/2009 |
4 | p 222 | 1. Using the Rectangle class from Chapter 8, Inheritance, add an initializer method according to the following declaration: -(Rectangle *) initWithWidth: (int) w: andHeight: (int) h; |
1. Using the Rectangle class from Chapter 8, Inheritance, add an initializer method according to the following declaration: -(Rectangle *) initWithWidth: (int) w andHeight: (int) h; |
5/11/2009 |
4 | p 226 | #import <stdio.h> // Define the Fraction class @interface Fraction : NSObject |
// Define the Fraction class @interface Fraction : NSObject |
5/11/2009 |
4 | p 251 | As already mentioned, conditional compilation is useful when debugging programs. You might have many printf calls embedded in your program that are used to display intermediate results and trace the flow of execution. | As already mentioned, conditional compilation is useful when debugging programs. You might have many NSLog calls embedded in your program that are used to display intermediate results and trace the flow of execution. |
5/11/2009 |
4 | p 255 | Note There are ways to work with multibyte characters at the Objective-C level, but Foundation provides a much more elegant solution with its NSString class. On the other hand, some applications can require you to use a lower-level approach, perhaps for the sake of optimization. If youre working with large arrays of data, for example, you might want to use the built-in array data structures of Objective-C instead of the array objects of Foundation (which are described in Chapter 15, Numbers, Strings, and Collections). Functions also come in handy if used properly to group repetitive operations and modularize a program.o |
Note There are ways to work with multibyte characters at the C level, but Foundation provides a much more elegant solution with its NSString class. On the other hand, some applications can require you to use a lower-level approach, perhaps for the sake of optimization. If youre working with large arrays of data, for example, you might want to use the built-in data structures of C instead of the array objects of Foundation (which are described in Chapter 15, Numbers, Strings, and Collections). Functions also come in handy if used properly to group repetitive operations and modularize a program. |
5/11/2009 |
4 | p 263 | Program 13.4 Output Programming is fun. |
Program 13.3 Output Programming is fun. |
5/11/2009 |
4 | p 273 | The remainder of today.year divided by 100 is calculated before being passed to the NSLog function so that just 04 displays for the year. | The remainder of today.year divided by 100 is calculated before being passed to the NSLog function so that just 09 displays for the year. | 5/11/2009 |
4 | p 310 | Several routines are available in the program library for doing such conversions: sscanf, atof, atoi, strtod, and strotol. In Part II, youll learn how to use a class called NSProcessInfo to access the command-line arguments as string objects instead of as C strings.a | Several routines are available in the program library for doing such conversions: sscanf, atof, atoi, strtod, and strtol. In Part II, youll learn how to use a class called NSProcessInfo to access the command-line arguments as string objects instead of as C strings.a | 5/11/2009 |
4 | p 325 | numberWithInt: initWithInt: intValueunsigned |
numberWithInt: initWithInt: intValue |
5/11/2009 |
4 | p 326 | This statement generates an error when the program is executed. All number objects must be newly created, meaning that you must invoke either one of the methods listed in the first column ofTable 15.1 on the NSNumber class or one of the methods listed in column 2 with the result from the alloc method: | This statement generates an error when the program is executed. All number objects must be newly created, meaning that you must invoke either one of the methods listed in the first column of Table 15.1 on the NSNumber class or one of the methods listed in column 2 with the result from the alloc method: | 5/11/2009 |
4 | p 327 | Program 15.2 Output Programming is fun In the line NSString *str = @Programming is fun; |
Program 15.2 Output Programming is fun In the line NSString *str = @Programming is fun; |
5/11/2009 |
4 | p 356 | The program sets up four address cards and then creates a new address book called Lindas Address Book. The four cards are then added to the address book using the addCard: method, and the list method is used to list the and verify that contents of the address book. | The program sets up four address cards and then creates a new address book called Lindas Address Book. The four cards are then added to the address book using the addCard: method, and the list method is used to list and verify the contents of the address book. |
5/11/2009 |
4 | p 359 | Program 15.12 Addressbook.h Interface File #import <Foundation/NSArray.h> #import AddressCard.h @interface AddressBook: NSObject { NSString *bookName; NSMutableArray *book; } -(AddressBook *) initWithName: (NSString *) name; |
Program 15.12 Addressbook.h Interface File #import <Foundation/NSArray.h> #import AddressCard.h @interface AddressBook: NSObject { NSString *bookName; NSMutableArray *book; } -(id) initWithName: (NSString *) name; |
5/11/2009 |
4 | p 361 | AddressBook *myBook = [AddressBook alloc]; AddressCard *myCard |
AddressBook *myBook = [AddressBook alloc]; AddressCard *myCard; |
5/11/2009 |
4 | p 366 | -(BOOL) writeToFile: path automically: (BOOL) flagy |
-(BOOL) writeToFile: path atomically: (BOOL) flagy |
5/11/2009 |
4 | p 376 | 10. Write a program that takes an array of NSInteger objects and produces a frequency chart that lists each integer and how many times it occurs in the array. Use an NSCountedSet object to construct your frequency counts. | 10. Write a program that takes an NSArray of NSNumber objects (where each NSNumber represents an integer) and produces a frequency chart that lists each integer and how many times it occurs in the array. Use an NSCountedSet object to construct your frequency counts. | 5/11/2009 |
4 | p 383 | For a 64-bit application, it can hold up to 8EB (thats exabytes) or 8,000GB of data! | For a 64-bit application, it can hold up to 8EB (thats exabytes) or 8 billion gigabytes of data! | 5/11/2009 |
4 | p 419 | Reread this explanation of the autorelease pool if it still seems a little fuzzy to you. When you understand Program 17.6, you will thoroughly understand of the autorelease pool and how it works. | Reread this explanation of the autorelease pool if it still seems a little fuzzy to you. When you understand Program 17.6, you will thoroughly understand the autorelease pool and how it works. | 5/11/2009 |
4 | p 436 | if ([glossary writeToFile: @glossary atomically: YES encoding: NSUTF8Encoding error: nil] == NO) NSLog (@Save to file failed!); [pool drain]; return 0; } |
if ([glossary writeToFile: @glossary atomically: YES] == NO) NSLog (@Save to file failed!); [pool drain]; return 0; } |
5/11/2009 |
4 | p 443 | [encoder encodeObject: bookName forKey: AddressBookBookName]; [encoder encodeObject: book forKey: @AddressBookBook]; |
[encoder encodeObject: bookName forKey: @AddressBookBookName]; [encoder encodeObject: book forKey: @AddressBookBook]; |
5/11/2009 |
4 | p 443 | Program 19.6 Test Program #import AddressBook.h #import <Foundation/NSAutoreleasePool.h> int main (int argc, char *argv[]) { NSString *aName = @Julia Kochan; ; |
Program 19.6 Test Program #import AddressBook.h #import <Foundation/NSAutoreleasePool.h> int main (int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString *aName = @Julia Kochan; ; |
5/11/2009 |
4 | p 447 | So to archive a short int, store it in an int first and then archive it with encodeInt:forKey:. Reverse the process to get it back: Use decodeInt:forKey: and then assign it to your short int variable. | So to archive a short int, store it in an int first and then archive it with encodeIntForKey:. Reverse the process to get it back: Use decodeInt:forKey: and then assign it to your short int variable.y | 5/11/2009 |
4 | p 448 | // Write the archived data area to a file if ([dataArea writeToFile: @myArchive atomically: YES encoding: NSUTF8Encoding error: nil] == NO) NSLog (@Archiving failed!); |
// Write the archived data area to a file if ([dataArea writeToFile: @myArchive atomically: YES] == NO) NSLog (@Archiving failed!); |
5/11/2009 |
4 | p 449 | The area you set aside and named dataArea now contains your archived objects in a form that you can write to a file. The message expression [dataArea writeToFile: @myArchive atomically: YES encoding: NSUTF8Encoding error: nil] == NO) sends the writeToFile:atomically:encoding:error: message to your data stream to ask it to write its data to the specified file, which you named myArchive. As you can see from the if statement, the writeToFile:atomically:encoding:error: method returns a BOOL value: YES if the write operation succeeds and NO if it fails (perhaps an invalid pathname for the file was specified or the file system is full). |
The area you set aside and named dataArea now contains your archived objects in a form that you can write to a file. The message expression [dataArea writeToFile: @myArchive atomically: YES] sends the writeToFile:atomically: message to your data stream to ask it to write its data to the specified file, which you named myArchive. As you can see from the if statement, the writeToFile:atomically: method returns a BOOL value: YES if the write operation succeeds and NO if it fails (perhaps an invalid pathname for the file was specified or the file system is full). |
5/12/2009 |
4 | p 450 | if (! dataArea) { NSLog (@Cant read back archive file!); Return (1); } |
if (! dataArea) { NSLog (@Cant read back archive file!); return 1; } |
5/12/2009 |
4 | p 451 | NSLog (@dataArray: ); for ( NSString *elem in dataArray ) NSLog (%@, elem); NSLog (@\ndataArray2: ); for ( NSString *elem in dataArray2 ) NSLog (%@, elem); [pool drsin]; return 0; } |
NSLog (@dataArray: ); for ( NSString *elem in dataArray ) NSLog (@"%@", elem); NSLog (@\ndataArray2: ); for ( NSString *elem in dataArray2 ) NSLog (@"%@", elem); [pool drain]; return 0; } |
5/12/2009 |
4 | p 457 | Whereas the Cocoa frameworks are designed for application development for Mac OS X desktop and notebook computers, the Cocoa Touch frameworks are for applications targeted for the iPhone and iTouch. | Whereas the Cocoa frameworks are designed for application development for Mac OS X desktop and notebook computers, the Cocoa Touch frameworks are for applications targeted for the iPhone and iPod Touch. | 5/12/2009 |
4 | p 459 | It combines what you learned while developing the first application with what youll learned throughout the rest of the book. | It combines what you learned while developing the first application with what you learned throughout the rest of the book. | 5/12/2009 |
4 | p 468 | Make sure your Inspector window is labeled Window Attributes, as shown in Figure 21.8. If it isnt, click on the leftmost tab in the top tab bar to get the correct window displayed. | Make sure your Inspector window is labeled Window Attributes, as shown in Figure 21.9. If it isnt, click on the leftmost tab in the top tab bar to get the correct window displayed. | 5/12/2009 |
4 | p 481 | -(void) processDigit: (int) digit; -(void) processOp: (char) op; -(void) storeFracPart; |
-(void) processDigit: (int) digit; -(void) processOp: (char) theOp; -(void) storeFracPart; |
5/12/2009 |
4 | p 484 | - (void)dealloc { [myCalculator dealloc]; [super dealloc]; |
- (void)dealloc { [myCalculator release]; [super dealloc]; |
5/12/2009 |
5 | p7 | Part 1 1 Introduction |
1 Introduction comes before the parts page. Removed. | 8/24/2009 |
5 | p25 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init; | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | 8/24/2009 |
5 | p39 | Chapter 8, Classes, Objects, and Methods deals with this topic in detail. | Chapter 8, Inheritance deals with this topic in detail. | 8/24/2009 |
5 | p50 | However, once again, its not guaranteed. | delete sentence | 8/24/2009 |
5 | p53 | charVar = 'W' | charVar = W | 8/24/2009 |
5 | p58 | This is because the value of a (100) would be added to the value of b (2) before multiplication by the value of Objective-C (25) would take place. | This is because the value of a (100) would be added to the value of b (2) before multiplication by the value of c (25) would take place. | 8/24/2009 |
5 | p59 | int result; | delete sentence | 8/24/2009 |
5 | p59 | This gives the intermediate result of 4. | This gives the intermediate result of 5. | 8/24/2009 |
5 | p67 | Add Note before Table 4.2 | Note: You wont use bitwise operators much, if at all, in your Objective-C programs. As this material may be a little dense for new programmers, you can just skim this section and refer back to it later, if necessary. |
8/24/2009 |
5 | p93 | Thus, 1234 % 10 gives a result of 123, and 123 % 10 gives you 3, which is the next digit of the reversed number. | Thus, 1234 / 10 gives a result of 123, and 123 % 10 gives you 3, which is the next digit of the reversed number. | 8/24/2009 |
5 | p136 | Program 7.2 Interface File Fraction.h | Program 7.1 Interface File Fraction.h | 8/24/2009 |
5 | p151 | (Fraction *) add: (Fraction *) f; | (Fraction *) add: (Fraction *) f | 8/24/2009 |
5 | p152 | resultFaction = [aFraction add: bFraction]; | resultFraction = [aFraction add: bFraction]; | 8/24/2009 |
5 | p156 | 2. Modify the print method from your Fraction class so that it takes an optional BOOL argument that indicates whether the fraction should be reduced for display. | 2. Modify the print method from your Fraction class so that it takes an additional BOOL argument that indicates whether the fraction should be reduced for display. | 8/24/2009 |
5 | p165 | Youll learn about categories in Chapter 11, Tying Up Some Loose Ends. | Youll learn about categories in Chapter 11, Categories and Protocols. | 8/25/2009 |
5 | p167 | -(void) setWidth: (int) w andHeight: (int) h | -(void) setWidth: (int) w andHeight: (int) h; | 8/25/2009 |
5 | p197 | [graphicObject perform: action] | [graphicObject performSelector: action] | 8/25/2009 |
5 | p210 | [myFoo setgGlobalVar: 100] | [myFoo setgGlobalVar: 100]; | 8/25/2009 |
5 | p227 | Program 11.1 is missing the last few lines of code. | } -(Fraction *) sub: (Fraction *) f { |
8/25/2009 |
5 | p245 | #define MakeFract(x,y) ([[Fraction alloc] initWith: x over: y]]) | #define MakeFract(x,y) ([[Fraction alloc] initWith: x over: y]) | 8/25/2009 |
5 | p245 | Delete the following: or even sum = [MakeFract (n1, d1) add: MakeFract (n2, d2)]; to add the fractions n1/d1 and n2/d2. |
fixed | 8/25/2009 |
5 | p351 | #import <Foundation/Foundation.h> | #import <Foundation/NSAutoreleasePool.h> | 8/25/2009 |
5 | p352 | Program 15.10 Addressbook.h Interface File | Program 15.10 AddressBook.h Interface File | 8/25/2009 |
5 | p353 | Program 15.10 Addressbook.m Implementation File | Program 15.10 AddressBook.m Implementation File | 8/25/2009 |
5 | p354 | If AddressBook is subclassed, the argument to initWithName: isnt an AddressBook object; its type is that of the subclass. | If AddressBook is subclassed, the receiver to the initWithName: message (and therefore the return value) isnt an AddressBook object; its type is that of the subclass. | 8/25/2009 |
5 | p420 | If you directly create an object using an alloc or copy method (or with an allocWithZone:, copyWithZone:, or mutableCopy method), you are responsible for releasing it. | If you directly create an object using the new, alloc, or copy method (or with an allocWithZone:, copyWithZone:, or mutableCopy method), you are responsible for releasing it. | 8/25/2009 |
5 | p422 | For your convenience, it is listed in Appendix D, Resources. | For your convenience, it is listed in Chapter 21, Writing iPhone Applications. | 8/25/2009 |
5 | p427 | ...but not why its copy was as well. When you get an element from a collection, you get a... | delete, as it repeats on p428 | 8/25/2009 |
5 | p436 | Missing last 2 lines of page: To read an XML property list from a file into your program, you use the dictionaryWithContentsOfFile: or arrayWithContentsOfFile: methods. To read |
fixed | 8/25/2009 |
5 | p486 | -(NSString *) convertToString; | -(NSString *) convertToString | 8/25/2009 |