NSUUID not unwrapped

I have been following the tutorial in the Beacon Tech Overview. I keep getting an error about not unpacking the NSUUID, but I cant find anything I am doing wrong from the tutorial.

Any help would be appreciated:

let beaconManager = ESTBeaconManager()

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
  
    self.beaconManager.delegate = self
    self.beaconManager.requestAlwaysAuthorization()
   
    self.beaconManager.startMonitoringForRegion(CLBeaconRegion(
        proximityUUID: NSUUID(UUIDString:"B9407F30-F5F8-466E-AFF9-25556B57FE6D"),
        // **ERROR= value of optional type NSUUID not unwrapped did you mean to use ! or ?**
        major: "39946", minor: "50893", identifier: "monitored region"))
    
    UIApplication.sharedApplication().registerUserNotificationSettings(
        UIUserNotificationSettings(forTypes: .Alert, categories: nil))
    
    return true
}

You need to add ! after NSUUID(...)

Before:

NSUUID(UUIDString:"B9407F30-F5F8-466E-AFF9-25556B57FE6D")

After:

NSUUID(UUIDString:"B9407F30-F5F8-466E-AFF9-25556B57FE6D")!

I already fixed the tutorial on our Dev Portal, thanks for sharing!

Thank you…

I bow down to your knowledge :smile:
Thanks
Brian

1 Like