ios - Objective C: Check if int exists, including zero -


i'm dealing addressbook, , want check if id set contact being created. however, address book id integer, i'm worried might 0 based. want like...

if (_contact.id) { ... } 

but run risk of assuming contact id 0 doesn't exist, though does. difficult problem test since involve setting new address book.

so question is, there way check if contact null/nil without assuming 0 means it's null? "is integer" function or nature?

if understand correctly, want check whether property set.

you can add @property (readonly, getter=isidset) bool idset , set backing ivar in setter id:

- (void)setid:(int)id {     _id = id;     _idset = yes; } 

then check if (contact.idset)

alternatively use nsnumber object , check if property nil.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -