NSNumbers are immutable, you have to create a new instance.
// Work with 64 bit to support very large values
myNSNumber = [NSNumber numberWithLongLong:[myNSNumber longLongValue] + 1];
// EDIT: With modern syntax:
myNSNumber = @([myNSNumber longLongValue] + 1);
For anyone who is using the latest version of Xcode (writing this as of 4.4.1, SDK 5.1), with the use of object literals, you can clean the code up even a little bit more...
NSNumber *x = @(1);
x = @([x intValue] + 1);
// x = 2
Still kind of a pain to deal with the boxing and unboxing everything to do simple operations, but it's getting better, or at least shorter.
For floating point stuff the short answer is the following, but it's a bad idea to do this, you'll loose precision and if you're doing any kind of comparison later like [myNSNumber isEqual:@(4.5)] you might be surprised:
myNSNumber = @(myNSNumber.floatValue + 1);
If you need to do math on floating point numbers represented as objects in Objective-C (i.e. if you need to put them in arrays, dictionaries, etc.) you should use NSDecimalNumber.
Lots of good info in the answers to this question. I used the selected answer in my code and it worked. Then I started reading the rest of the posts and simplified the code a lot. It’s a bit harder to read if you aren’t familiar with the changes in notation that were introduced in Xcode 5, but it’s a lot cleaner. I probably could make it just one line, but then it’s a little too hard to figure out what I’m doing.
I’m storing an NSNumber in a dictionary and I want to increment it. I get it, convert it to an int, increment it while converting it to an NSNumber, then put it back into the dictionary.