What w开发者_如何学Goould be the best way to see if an NSDate is actually set to a date or is empty? Returning its description or changing it to string returns "(null)"...?
Thanks.
If you want to see if an instance of NSDate
(or any object) is nil, just compare it to nil. A non-null NSDate
object will never be empty; it always contains a date. Both -init
and +date
return an NSDate
object initialized to the current date and time, and there is no other way to create an instance of this class.
if(someData == nil) {
// do stuff
}
if it doesn't hold a date, then you have a nil pointer, so simply
if (!date) {
...
}
or more explicitly
if (date == nil) {
...
}
精彩评论