I have a Rectangle object with the following interface:
@interface Rectangle : NSObject
@property int height, width;
-(void) setWidth:(int)w andHeight: (int)h;
@end
I have an implementaion of it and an object (say r
) made from it. When I call
[r setWidth: 5 andHeight: 6];
I get the correct results when I verify it through [r height]
. However, when I am using performselector
to do the same:
NSNumber *myNumber = [NSNumber numberWithInt:45];
[r performSelector:@selector(setWidth:andHeight:) withObject:myNumber
withObject:myNumber];
calling [r height]
prints some garbage value (looks like some address) wen the expected value is 45. What am I doing wrong?
NSNumber
isn't the same asint
. Your method doesn't takeNSNumber
objects as parameters. BTW - why are you usingperformSelector
instead of calling the method directly?NSNumber
instead ofint
.