Note that there are some explanatory texts on larger screens.

plurals
  1. PONSDecimalNumbers in Array Causing "Unrecognized Selector..." messages
    primarykey
    data
    text
    <p>Ive been playing around with obj-c for a few months now and feel comfortable with a lot of things but cant make sense of something that seems very simple. I need to be able to go from an NSString split into an array then get the NSDecimalNumbers from that array. If I try to perform any calculations, I get an "unrecognized selector sent to instance." If I simply print each decimal number everything goes smoothly. If I put the values manually into NSDecimalNumbers rather than pulling from the array that also works. The error and code are below.</p> <blockquote> <p>2013-10-14 15:54:42.174 test[30829:c07] -[__NSCFString decimalNumberByAdding:]: unrecognized selector sent to instance 0x75a81f0 2013-10-14 15:54:42.176 test[30829:c07] <strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString decimalNumberByAdding:]: unrecognized selector sent to instance 0x75a81f0' *</strong> First throw call stack: (0x1c90012 0x10cde7e 0x1d1b4bd 0x1c7fbbc 0x1c7f94e 0x2075 0x10e1705 0x152c0 0x15258 0xd6021 0xd657f 0xd56e8 0x44cef 0x44f02 0x22d4a 0x14698 0x1bebdf9 0x1bebad0 0x1c05bf5 0x1c05962 0x1c36bb6 0x1c35f44 0x1c35e1b 0x1bea7e3 0x1bea668 0x11ffc 0x1bfd 0x1b25) libc++abi.dylib: terminate called throwing an exception</p> </blockquote> <pre><code>-(IBAction)buttonPushed: (id) sender { NSString* s = @"25.55, 109.24"; NSArray* a = [s componentsSeparatedByString: @" "]; NSDecimalNumber* dec1 = [a objectAtIndex: 0]; NSDecimalNumber* dec2 = [a objectAtIndex: 1]; NSDecimalNumber* sum = [dec1 decimalNumberByAdding: dec2]; statusText.text = [NSString stringWithFormat: @"%@", sum, nil]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload