पर CLLocationManager के लिए ऑथ का अनुरोध कैसे करें I docs के अनुसार, CLLocationManager का उपयोग करने वाले स्विफ्ट 3 में एक ओएसएक्स ऐप लिख रहा हूं और मुझे जो भी उदाहरण मिलते हैं, वे ठीक होना चाहिए (यह एक वर्ग में है एक CLLocationManagerDelegate
)मैकोज़
if CLLocationManager.locationServicesEnabled() {
let lm = CLLocationManager()
lm.requestWhenInUseAuthorization()
lm.delegate = self
lm.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
lm.startUpdatingLocation()
print("should start getting location data")
} else {
print("Location service disabled");
}
है लेकिन ऐसा लगता है requestWhenInUseAuthorization
(और requestAlwaysAuthorization
) OSX के लिए उपलब्ध नहीं हैं।
#if os(macOS)
// can't find way for MacOSX to request auth
#endif
#if os(watchOS) || os(tvOS)
lm.requestWhenInUseAuthorization()
#endif
#if os(iOS)
lm.requestAlwaysAuthorization()
#endif
तो किसी को पता है कि कैसे एक MacOS डेस्कटॉप अनुप्रयोग में इस काम के पाने के लिए: मैं वर्तमान में उन फ़ंक्शन कॉल #if
ब्लॉक में लिपटे मिल गया है?