I have an array that has:
12,
"+",
56,
"+",
"",
"(",
56,
"+",
65,
")"
now let us say i want to add
[NSMutableArray objectAtIndex: 1] + [NSMutableArray objectAtIndex: 3]
i know i need to convert the array parts to NSNumber, but i can not find anything that says how to do that if thats possible. Also i should add that the numbers are put in as NSString and to change that will be very painful and can be done as a last resort.
You can get a nsnumber from a string like so:
So to convert from an array to an nsnumber:
But keep in mind that you can’t directly add two nsnumber objects together, it would have to be something like this:
And if you end up using float values, you can just replace
intValuewithfloatValue