Reputation: 5754
I have an Objective-C function as follows:
-(float)getModelTotal: (int)amount forSelector: (NSString*)selectorType;
I would like to perform the following steps in a different funciton:
float programFee = 1;
float token = [self getModelTotal: object.Alpha forSelector: object.Beta];
programFee += token;
object.Alpha
is an integer and object.Beta
is an NSString
.
The function returns a float and I would like to add the result to a different float. When I invoke the function by sending a message to self
, I get an error and rightfully so because the float is not self
in this case.
To what receiver should I send this message?
Upvotes: 0
Views: 188
Reputation: 19943
That's not a function, it's a method. You should send the message to an instance of whichever class you declared the method on.
If you want a function, declare it C-style, but outside of the @implementation
block.
Update: It seems like it's telling you Object.Alpha
is really an NSNumber
? Try:
float token = [self getModelTotal: [object.Alpha intValue] forSelector: object.Beta];
Upvotes: 1
Reputation: 17143
Ok, well, object.alpha is apparently an NSNumber, not an int.
So you should make the call something like this:
[self getModelTotal: [object.alpha intValue] forSelector:object.beta]
Upvotes: 0