NSNumber* myNumber = [NSNumber numberWithDouble:10.0]; [self setNumber:myNumber];
self.number = [NSNumber numberWithDouble:10.0];
Copyright © Scott Stevenson 2004-2015
by Scott Stevenson — Oct 11
The problem here is just the syntax. To call a method named "-setNumber:", you need to do something like this:
NSNumber* myNumber = [NSNumber numberWithDouble:10.0]; [self setNumber:myNumber];
You only use the equals sign when setting a variable or property value. You could probably also get away with this in Objective-C 2.0:
self.number = [NSNumber numberWithDouble:10.0];
Stylistically, though, you should probably actually define a @property if you're going to do that.