Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define a function that returns a String in Objective-C / Iphone SDK

I am an Objective C noob and need a bit of help.

I need to pass a function 2 integers A and B.

The called function then checks if A > B, A = B or A < B and passes back a string.

If A > B then it must pass back "HOT"

If A = B then it must pass back "MEDIUM"

If A < B then it must pass back "COLD"

Also how do I call this function from within another function?

Any help would be appreciated.

Thanks.

like image 641
Dalan Avatar asked Jun 04 '10 15:06

Dalan


1 Answers

-(NSString*) myMethod: (int) one two:(int)two {
     if( one > two ) return @"HOT";
     if( one == two ) return @"MEDIUM";
     return @"COLD";
}

You can then call this like such:

[myObject myMethod:10 two:30]; //returns "COLD"
like image 129
Jacob Relkin Avatar answered Oct 20 '22 01:10

Jacob Relkin