I want make a function to include in my code to calculate percentages.
In Php, it’s :
function percent(a,b){
return a/b*100;
}
In Objective C, I don’t know. I tried:
-(void)percent(a,b){
return a/b*100;
}
But there are 2 errors. Could you me explain how to make it work?
Thank you for you help
The more correct way to do this will be:
This way you use a more correct naming convention , you actually return a float and your safe in case some one gave you the value 0 in B.
(which should be covered by documentation)