I'm really newbie developing iphone apps, and I got a question...
I would like to know how must I do to receive the var that my function returns.
Take a look:
-(void)myfunc{
float num1 = 2.50;
float num2 = 3.50;
//here is my doubt, how can I get the value that function returns?
float 开发者_如何学编程varreceived = [self getNumber:num1:num2];
}
//the function that receive the vars and returns a value
-(float)getNumber: (float)var1 :(float)var2 {
NSLog(@"1->%f",var1);
NSLog(@"2->%f",var2);
return 3.23;
}
I receive this error when I build:
"error: void value not ignored as it ought to be"
in this line:
float varreceived = [self getNumber:num1:num2];
Update:
Nop, I receive this error when I build:
"error: void value not ignored as it ought to be"
in this line:
float varreceived = [self getNumber:num1:num2];
Max:
then you probably declared the -(float)getNumber: (float)var1 :(float)var2 as -(void)getNumber: (float)var1 :(float)var2 in your header
HispaJavi:
Yeah!! this is the problem, I wrote "-(void)getNumber" in header! I changed it "-(float)getNumber" and it works!! thanks!!
Everything is OK. You'll receive 3.23
精彩评论