In my core data model, I have an entity with an optional NSNumber attribute.
How do I test to see if the value in that attribute is valid or not?
When I test for nil... doesn't work.
[self numberAttribute] == nil // always returns NO
When I test for a zero value int, that doesn't work.
[[self numberAttribute] intValue] == 0 // always returns no
As a matter of fact, [[self numberAttribute] intValue]] returns something that looks suspiciously like a pointer to a memory address.
Anyone have any idea what I am doing wrong?
EDIT: OK, the bug was in a totally unrelated part of the code. NSNumber and Core Data are functioning exactly as one would expect. That said, I am going to go with the suggested approach of making the attribute non-optional and specifying 0 as the default value.
Just putting this note here for a little while for anyone who was watching this question, then I am deleting it.