Saturday, 15 January 2011

objective c - Incrementing number in NSArray: Is there a shorter syntax? -


I have an array of many NSNumber at one time I want to increase a number within an array. Here's how I do this:

  map [2] = [nsnumber number power: [map [2] integer value] + 1]  

Convert me the number to NSING, change the NASRRA to NSNRA only after accepting it again at the NNumber Number.

It seems very wrong is there a better way to do this?

You can call it @ (...) syntax:

Map [@ 2] = @ ([Map [@ 2] Integer Value) + 1); However, the general approach remains the same, because the NSNumber items are irreversible if cocoa has provided the NSMutableNumber class, then it It would be easy, but it is missing from the structure.

If you want to save a new NSNumber example, every time the price increases, you can create an unstable object similar to NSNumber Which will support in-place increments, decants and so on.


No comments:

Post a Comment