I need to compare two numbers in a cocoa application, but it doesn't allow me to use the regular signs (>=, <=, <, >) nor will it let me use isGreaterThanOrEqualTo:[] (Which, I undestand only takes an object, but I thought I would try it). So can someone please tell me how you accomplish this? Thank you in advance.

Have you tried something like this:

if (num1 == num2) {
    //Do something.
}
else if (num1 == num3) {
    //Do another thing.
}
else if (num2 == num3) {
    //Do another thing.
}
else {
    //Do a third thing.
}

To be honest I have never really worked with Cocoa but I have a hard time believing that something like what I've done above is not possible.

Have you tried something like this:

// code snippet was here

To be honest I have never really worked with Cocoa but I have a hard time believing that something like what I've done above is not possible.

I know. It's quite odd, but I have tried just plainly entering in the symbols, but I get syntax errors everytime.It's something rather simple that I just haven't stumbled across yet.

Edited 3 Years Ago by pars99

Objective C is a bit tricky with numbers, you can mix it with C but the NSNumbers are tricky. Check out the NSNumbers and operators, you have to assign the values of the NSNumber to a variable and then you cand use this aritmethic operations.

This question has already been answered. Start a new discussion instead.