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.

Recommended Answers

All 4 Replies

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.

Can you post the error messages and the relevant code?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.