I can’t imagine a “clean” or efficient method of doing this.
I would like to transform a string of numbers like @”1234″ into an array of shorts for a calculator pet project*.
I think of getting substrings and then the intValue of the substring but it sounds cumbersome and overkill. Would there be a more elegant way of doing it?
Thanks in advance!
* I know that there are more efficient ways to do maths and plenty of C libraries do this but it’s for my own education :-).
If I have this straight, you want to turn an NSString into a short array? This function assumes each character in the NSString is a separate short. Oh, and don’t forget to free that array when you’re done with it!