beacon minor variable global

时间:2016-07-11 20:41:46

标签: ios swift beacon

i need ur help! i do an app and i need said that the "minorBeacon" do a global variable, because in other ViewController i will called. but i can't and the other problem is convert this data to "Int"

    func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {

    if let beacon = beacons.first {
    var minorBeacon : Int = beacon.minor
       print(minorBeacon)


        }

the problem says "cannot convert value type "NSNumber" to specified type "Int" " help me please!!

Thanks Guys ! :)

1 个答案:

答案 0 :(得分:1)

You can user intValue to get the NSNumber's value as a Swift Int:

func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {

if let beacon = beacons.first {
    var minorBeacon = beacon.minor.intValue
    print(minorBeacon)
}