1 These tools should be preinstalled on all Macs that came with OS X. If you separately installed OS X, then make sure you install the Developer Tools as well.
2 CygWin is a Unix environment that runs under Windows. The good news is that it's free. However, you should be aware that Objective-C support is not normally provided with the compiler that is distributed with CygWin.
1 Appendix B discusses methods for storing characters from extended character sets, through special escape sequences, universal characters, and wide characters.
2 As of this writing, the gcc
compiler version 3.3 does not have full support for these data types.
1 This is a feature added to the 1999 ANSI C Standard (sometimes referred to as C99). If you're using gcc
and you get an error trying to use this feature, try adding the –std=c99
option to the gcc
command line.
1 It's better to use routines in the standard library called islower
and isupper
and avoid the internal representation issue entirely. To do that, include the line #import <ctype.h>
in your program. However, we've put this here for illustrative purposes only.
2 The type BOOL
is really added by a mechanism known as the preprocessor.
1 We only briefly mentioned it up to this point, but alloc
and init
are methods you have used all along that are never defined in your classes. That's because you took advantage of the fact that they were inherited methods.
2 There are some ways to coerce the use of this method, but we won't get into that here—besides, it's not good programming practice.
3 Of course, it also has instance variables that it inherits from the Object
class, but we choose to ignore this detail for now.
1 As described more completely in Chapter 13, “Underlying C Language Features,” the system always carries information about to which class an object belongs. That enables it to make these key decisions at runtime instead of at compile time.
2 There are ways to invoke methods that are specified by a variable, in which case the compiler can't check that for you.
3 You can also catch an error by overriding the doesNotRecognize:
method. This method will get invoked whenever an unrecognized message is sent to a class and is passed the unrecognized selector as its argument. You can even forward the message to another message using the forward::
method.
1 Bit fields are briefly discussed in Chapter 13.
1 Note that when using NSObject
as your root object, this method is poseAsClass:
.
2 As you'll learn in Part II, the root object for the Foundation framework is not Object
but NSObject
.
3 Well that's the theory, anyway. The compiler lets you say you conform to a protocol and issues warning messages only if you don't implement the methods.
4 For the value of π, you can use the value 3.141592654 or take advantage of the special defined value M_PI
from the math.h
header file.
1 GNU advocates do not encourage use of the #import
and claim its support might be phased out. Apple uses the #import
directive extensively and will likely continue supporting it into the future. Because #import
enables a programmer to more easily avoid accidental multiple inclusion of a file and thus reduce the chance of errors, we've chosen to adopt that method in this text for the inclusion of files.
2 With gcc implementations, these values are not specified directly in limits.h
but in a header file that is included by limits.h
.
1 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.
2 The following point might sound a bit confusing now, but in Chapter 15, “Numbers, Strings, and Collections,” we'll clear this up: The constant character strings we mention here are called C-style strings. These are not objects. In Objective-C, a constant character string object can be created by putting an @
sign in front of the string, as in @"This is okay."
You can't substitute one for the other. Again, Chapter 15 clears up this point for you.
1 You also need to release objects created by a copy method, as you'll learn in Chapter 17, “Memory Management.”
2 Currently, unichar
characters occupy 16 bits, but the Unicode standard provides for characters larger than that size. So, in the future, unichar
characters might be larger than 16 bits. The bottom line is to never make any assumption about the size of a Unicode character.
3 If you're using GNUStep, the default data type for a constant character string might be NXConstantString
. If that's the case, you'll run into problems when working with the NSString
class. You might need to use the gcc command-line option –fconstant-string-class=NSConstantString
to change the default for the constant string class.
4 The printf
function comes from the underlying C language, which doesn't know anything about objects.
5 You can read about structures in Chapter 13, “Underlying C Language Features.” However, you can probably gain enough information to work with them from the discussion that follows in the text.
6 Mac OS X provides an entire Address Book framework, which offers extremely powerful capabilities for working with address books.
7 You also might want an initWithName:andEmail:
initialization method, but we won't show that here.
8 There's also a method called sortUsingFunction:context:
that lets you use a function instead of a method for performing the comparison.
9 A more general method could implement an NSLog
approach and invoke each object's description
method for displaying each member of the set. That would allow sets containing any types of objects to be displayed in a readable format.
1 The conventions of using slash to separate directories and a period to separate a filename from its extension do not necessarily have to be those adopted by the underlying file system.
1 If you're writing Cocoa applications, the pool is automatically set up for you. But because you're just writing Foundation applications here, you need to set up the pool yourself.
2 If the str
variable is nil
, that's not a problem. All instance variables are initialized to nil
by the Objective-C runtime, and it's okay to send a message to nil
.
1 If you completed exercise 3 at the end of Chapter 17, you already have a Fraction
class that works under Foundation.
1 The Mac also supports binary serialized property lists through the NSPropertyListSerialization
class, which we won't describe here.
2 Note that as of this writing that keyed archiving is not supported under GNUStep.
1 You can find out which version of the compiler you're running with the command gcc –v
. You can also give the gcc
command the –std=c99
option to get more support for C99 features than is offered by default.
2 You can get a description of the GNU extensions at http://www.gnu.org/software/gcc/onlinedocs.
3 This also applies to unions.
4 As noted in the text, on non-Mac systems, the gcc compiler issues a warning message advising against the use of this statement and recommending the use of #include
instead.
18.189.178.237