Hi, in this sample method/message:
-(void) setNumerator:(int) n {
numerator = n;
}
What does the (int) mean? It doesn't look like its casting to an int...
Hi, in this sample method/message:
-(void) setNumerator:(int) n {
numerator = n;
}
What does the (int) mean? It doesn't look like its casting to an int...
The (int) is a type specifier. It means that the variable (in this case, "n") is of the type "int".
int
refers to the type of n
. When sending the -setNumerator:
message, you need to supply an argument. In this case you would supply an argument of type int
.
if your method had a definition like:
- (void)setNumerator:(NSNumber *)n {
NSNumber *newNumerator = [n copy];
[numerator release];
numerator = newNumerator;
}
you would then supply an NSNumber
when sending -setNumerator:
.