- Aggregate initialization
Object [] a = {new Object(), new Object()};- Dynamic Aggregate Initialization
Object [] b;
b = new Object [] {new Object(), new Objet()};
Saturday, January 10, 2009
Array Initializaion
Sunday, November 30, 2008
ill-conditioned is a least-squares problem
In same cases, the normal equations for a least-squares problem can be ill-conditioned; that is, small errors in the calculations of the entries of ATA can sometimes cause relatively large errors in the solution ˆx. If the columns of A are linearly independent, the least-squares solution can often be computed more reliably through a QR factorization of A.
Features of a Calculator
- Formula Display
- Matrix
- Unit converter
- Constant Search and Use
To be continued...
Friday, November 28, 2008
Types and Contants in Objective-C
Objective-C programmers use a few types that are not found in the rest of the C world.
- id is a pointer to any type of object
- BOOL is the same as char, but is used as a Boolean value.
YES is 1.
NO is 0. - IBOutlet is a macro that evaluates to nothing. Ignore it. (IBOutlet is a hint to Interface Builder when it reads the declaration of a class from a .h file.)
- IBAction is the same as void. It also acts as a hint to Interface Builder.
- nil is the same as NULL. We use nil instead of NULL for pointers to objects.
Sunday, November 23, 2008
Initializer
A few of the initializers in Cocoa will return nil if initialization was impossible. A programmer who is worried that the superclass's initializer may be one of these cases will create an initializer that is something like this:
Conventions for Creating Initializers
The day will come when you will create a class that must, must, must have an argument supplied. Override the superclass's designated initializer to throw an exception:
- (id)init
{
if (![super init])
return nil;
firstNumber = random() % 100 + 1;
secondNumber = random() % 100 + 1;
return self;
}
This version will always work and is considered the most correct form; however, none of the classes that you will subclass in this book require these checks. For simplicity, this book will sometimes leave out the check.
Conventions for Creating Initializers
Following are rules that Cocoa programmers try to follow regarding initializers.
You do not have to create any initializer in your class if the superclass's initializers are sufficient.
If you decide to create an initializer, you must override the superclass's designated initializer.
If you create multiple initializers, only one does the work—the designated initializer. All other initializers call the designated initializer.
The designated initializer of your class will call its superclass's designated initializer.
The day will come when you will create a class that must, must, must have an argument supplied. Override the superclass's designated initializer to throw an exception:
- (id)init
{
[self dealloc];
@throw [NSException exceptionWithName:@"BNRBadInitCall"
reason:@"Initialize Lawsuit with initWithDefendant:"
userInfo:nil];
return nil;
}
Possible Tokens in the Calendar Format String
Subscribe to:
Posts (Atom)