Theocacao
Leopard
Design Element
Comment on "A Quick Objective-C 2.0 Tutorial: Part II"
by charles castille — Oct 09
Sorry for the late comment, but I am looking for some advice on
categories. I am working with the example code provided by Apple on page
48 of the Obj C language description.

The problem I have entails calling a function defined in the extension
from within a function defined in the original class. Referring to the
code example described above, suppose I call the setNumber method
defined in the extension, from within init, defined in the MyObject interface. If I do this, the compiler returns an error saying setNumber is not known. Example code is provided below.

#import "MyObject.h" @interface MyObject ( ) -(void)setNumber:(NSNumber *)newNumber; -(void)resetNumber; @end @implementation MyObject -(NSNumber *)number { return number; } -(id)init{ setNumber = [[NSNumber alloc] initWithDouble:10]; /*error*/ return self; } -(void)setNumber:(NSNumber *)newNumber { number = newNumber; } @end
Back to "A Quick Objective-C 2.0 Tutorial: Part II"
Design Element

Copyright © Scott Stevenson 2004-2015