I write a finance-based application, and I need custom behavior for NSDecimalNumber operations, so I call [NSDecimalNumber setDefaultBehavior:(MyHandlerSubclass)] on application launch. However, I just found out from the NSDecimalNumber header file that it needs to be called on each thread decimal number calculations might be run on.
I could explicitly call [(NSDecimalNumber *) performOperation:withBehavior:], passing my MyHandlerSubclass each time, but it grows verbose and tiring. Is there any way to eliminate the verbosity, maintain the setDefaultBehavior:, and not have to worry about calculations being done on different threads with the wrong behavior? It sounds like I’d have to write my own wrapper to do so.
That seems unmanageable in the context of queues. There is no guarantee what thread any given GCD queue might run on, be it one of your own creation or one of the system provided queues. (Obviously, the main queue is an exception to this rule).
The documentation says nothing about this limitation. Either the docs are wrong or the header is wrong…
… and it is the docs (Disassembly is my friend). File a bug.
There doesn’t seem to be a way to avoid using the more verbose form save for calling +setDefaultBehavior: at the beginning of any scheduled block (to cover the arbitrary thread issue).
File a bug asking for an enhancement as the current behavior doesn’t make sense in a queue based world (and put the bug # here, please).