Reputation: 2266
I am new to Objective C. I am trying to write a void function in my implementation file with arguments however xcode doesn't like that. I did some research and it appears I can't do that.
This is what I am trying to do basically:
-(void)findMilesLeft(float x, float y)
{
float gallons = x;
float miles = y;
}
I would be calling this findMilesLeft within another void function- I believe I would call it as:
-(void)changeSUV
{
[self findMilesLeft(20, 100)];
}
Obviously I have tried this syntax and it didn’t work for me… is there some way I can execute this correctly?
The calculations arent in here obviously but I think the idea is clear.
Thanks, John
Upvotes: 0
Views: 1077
Reputation: 991
The correct syntax is:
-(void)findMilesLeftWithX:(float)x andY:(float)y
{
float gallons = x;
float miles = y;
}
And then you call it like that:
-(void)changeSUV
{
[self findMilesLeftWithX:20 andY:100];
}
If you didn't do it yet, you should probably read this document :):
Upvotes: 6