check if NSNumber is empty

后端 未结 5 1068
醉话见心
醉话见心 2021-02-07 05:28

How do I check if a NSNumber object is nil or empty?

OK nil is easy:

NSNumber *myNumber;
if (myNumber == nil)
    doSomething

But if th

5条回答
  •  天涯浪人
    2021-02-07 05:53

    Dealing with Swift 2.0 and Parse:

    var myNumber = yourArray!.objectForKey("yourColumnTitle")
        if (myNumber == nil) {
        myNumber = 0
          }
    

    In my case, I then had to:

        let myNumberIntValue = myNumber!.intValue
    

提交回复
热议问题