4

I have declared one variable as NSNumber and assigned bool true. Then I have declared another NSNumber and assigned int 1.

When I try to retrieve the datatype of both variables, both returns as Int. This issue happened only in iPhone 5 and lower which is 32bit architecture.

How to resolve this issue?

var number: NSNumber = 1
var boolienValue: NSNumber = true

func getType(value: AnyObject) -> String? {

    if value is Int {
        return "Int"
    } else if value is Bool {
        return = "Bool"
    }
    else if value is Double {

        return = "Double"
    }
    return nil
}
Bhavin Ramani
  • 3,221
  • 5
  • 30
  • 41
Who am I
  • 83
  • 3
  • Possible duplicate of [Determine that `true` is a Bool and not a number equal to 1](http://stackoverflow.com/questions/37597619/determine-that-true-is-a-bool-and-not-a-number-equal-to-1). – Martin R Nov 11 '16 at 12:07
  • 3
    Possible duplicate of [Is there a correct way to determine that an NSNumber is derived from a Bool using Swift?](http://stackoverflow.com/questions/30215680/is-there-a-correct-way-to-determine-that-an-nsnumber-is-derived-from-a-bool-usin) – user28434'mstep Nov 11 '16 at 12:16

0 Answers0