swift - NSDecimalNumber.adding from NSManagedObjects hitting unrecognized selector issue -
first, let me thank in community in advance in getting me out of jam.
my app hits runtime error, , i've isolated line causing error.
when attempt add 2 nsdecimalnumber variables use .adding method, receive "unrecognized selector sent instance" error:
terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfnumber decimalnumberbyadding:]: unrecognized selector sent instance 0x608002c361a0'
i've created dummy nsdecimalnumber variables try , debug issue, , seem work fine when adding. however, when working nsmanagedobject variables (result
, newtransaction
) have nsdecimalnumber variables, run error.
below code causing these issues:
//testing dummy variables let a1 = nsdecimalnumber(decimal: 5.2) let a2 = nsdecimalnumber(decimal: 10.8) print ("a1: \(a1), a2: \(a2)") //a1: 5.2, a2: 10.8 let a3 = a1.adding(a2) print ("a3: \(a3)") //a3: 16 //great, above works fine. //now let's try using nsmanagedobjects, defined in section let = result.netchange //result.netchange of class nsdecimalnumber let b = newtransaction.amount //newtransaction.amount of class nsdecimalnumber print ("a: \(a), b: \(b)") //a: 444.12, b: 22.23 let c = a.adding(b) //<---this app crashes print ("c: \(c)") //does not print, app has stopped
my question: why dummy variables able add each other, while nsmanagedobject variables cannot?
thanks again!
a core data property of type "double" stored nsnumber
in managed object context. not sufficient change type in nsmanagedobject
subclass because accessor methods created dynamically @ runtime. code compiles, crashes @ runtime because variable nsnumber
, not nsdecimalnumber
.
the solution set type "decimal" in core data model inspector.
Comments
Post a Comment