前提・実現したいこと
プログラムの37行目
Xcodelocation!.fetchInBackgroundWithBlock { (error: NSError!) -> Void in
に
Ambiguous use of 'fetchInBackgroundWithBlock'
というエラーが出て困っています.
発生している問題・エラーメッセージ
Ambiguous use of 'fetchInBackgroundWithBlock'
該当のソースコード
Swift
1import UIKit 2 3 4class NotificationManager: UIViewController, CLLocationManagerDelegate { 5 6 //CLLocationManagerクラスのプロパティを用意 7 var mLocationManager : CLLocationManager! 8 9 init() { 10 //プロパティの初期化 11 self.mLocationManager = CLLocationManager.init() 12 super.init(nibName: nil, bundle: nil) 13 //CLLocationManagerのデリゲート設定 14 self.mLocationManager.delegate = self 15 //位置情報を利用する許可画面を表示 16 self.mLocationManager.requestWhenInUseAuthorization() 17 } 18 19 required init?(coder aDecoder: NSCoder) { 20 fatalError("init(coder:) has not been implemented") 21 } 22 23 func searchLocation (locationId: String, callback:(NSError?)->Void) { 24 //Locationクラスを指定したNCMBObjectインスタンスを作成 25 let location = NCMBObject(className: "Location") 26 //引数のlocationIdをインスタンスのobjectIdに設定 27 location?.objectId = locationId 28 29 location!.fetchInBackgroundWithBlock { (error: NSError!) -> Void in 30 if ((error) != nil) { 31 callback(error) 32 } else { 33 //取得した位置情報をpointに設定 34 let point : NCMBGeoPoint = location.objectForKey("geo") as! NCMBGeoPoint 35 //Location Notificationを再設定 36 self.setLocationNotification( 37 point, 38 callback: { (error : NSError?) -> Void in 39 if ((error) != nil) { 40 callback(error) 41 } else { 42 callback(nil) 43 } 44 }) 45 } 46 } 47 } } 48}
試したこと
エラーについて調べたところ,fetchInBackgroundWithBlockの曖昧な利用をしてしまっているということはわかりました.
fetchInBackgroundWithBlockをどこかで宣言すればいいのでしょうか.
補足情報(FW/ツールのバージョンなど)
使っている環境
Xcode10.1
Swift4.2.1
ニフティクラウドのmobilebackendを使っています.