pub struct CLLocationManager { /* private fields */ }CLLocationManager only.Expand description
Implementations§
Source§impl CLLocationManager
impl CLLocationManager
pub unsafe fn locationServicesEnabled_class() -> bool
pub unsafe fn headingAvailable_class() -> bool
pub unsafe fn significantLocationChangeMonitoringAvailable() -> bool
Sourcepub unsafe fn isMonitoringAvailableForClass(region_class: &AnyClass) -> bool
pub unsafe fn isMonitoringAvailableForClass(region_class: &AnyClass) -> bool
§Safety
region_class probably has further requirements.
pub unsafe fn regionMonitoringAvailable() -> bool
pub unsafe fn regionMonitoringEnabled() -> bool
pub unsafe fn isRangingAvailable() -> bool
pub unsafe fn accuracyAuthorization(&self) -> CLAccuracyAuthorization
pub unsafe fn isAuthorizedForWidgetUpdates(&self) -> bool
pub unsafe fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn CLLocationManagerDelegate>>>
CLLocationManagerDelegate only.Sourcepub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn CLLocationManagerDelegate>>,
)
Available on crate feature CLLocationManagerDelegate only.
pub unsafe fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn CLLocationManagerDelegate>>, )
CLLocationManagerDelegate only.Setter for delegate.
This is a weak property.
pub unsafe fn locationServicesEnabled(&self) -> bool
pub unsafe fn purpose(&self) -> Option<Retained<NSString>>
Sourcepub unsafe fn setPurpose(&self, purpose: Option<&NSString>)
👎Deprecated: Set the purpose string in Info.plist using key NSLocationUsageDescription
pub unsafe fn setPurpose(&self, purpose: Option<&NSString>)
pub unsafe fn activityType(&self) -> CLActivityType
Sourcepub unsafe fn setActivityType(&self, activity_type: CLActivityType)
pub unsafe fn setActivityType(&self, activity_type: CLActivityType)
Setter for activityType.
pub unsafe fn distanceFilter(&self) -> CLLocationDistance
CLLocation only.Sourcepub unsafe fn setDistanceFilter(&self, distance_filter: CLLocationDistance)
Available on crate feature CLLocation only.
pub unsafe fn setDistanceFilter(&self, distance_filter: CLLocationDistance)
CLLocation only.Setter for distanceFilter.
pub unsafe fn desiredAccuracy(&self) -> CLLocationAccuracy
CLLocation only.Sourcepub unsafe fn setDesiredAccuracy(&self, desired_accuracy: CLLocationAccuracy)
Available on crate feature CLLocation only.
pub unsafe fn setDesiredAccuracy(&self, desired_accuracy: CLLocationAccuracy)
CLLocation only.Setter for desiredAccuracy.
pub unsafe fn pausesLocationUpdatesAutomatically(&self) -> bool
Sourcepub unsafe fn setPausesLocationUpdatesAutomatically(
&self,
pauses_location_updates_automatically: bool,
)
pub unsafe fn setPausesLocationUpdatesAutomatically( &self, pauses_location_updates_automatically: bool, )
Setter for pausesLocationUpdatesAutomatically.
pub unsafe fn allowsBackgroundLocationUpdates(&self) -> bool
Sourcepub unsafe fn setAllowsBackgroundLocationUpdates(
&self,
allows_background_location_updates: bool,
)
pub unsafe fn setAllowsBackgroundLocationUpdates( &self, allows_background_location_updates: bool, )
Setter for allowsBackgroundLocationUpdates.
pub unsafe fn showsBackgroundLocationIndicator(&self) -> bool
Sourcepub unsafe fn setShowsBackgroundLocationIndicator(
&self,
shows_background_location_indicator: bool,
)
pub unsafe fn setShowsBackgroundLocationIndicator( &self, shows_background_location_indicator: bool, )
Setter for showsBackgroundLocationIndicator.
pub unsafe fn location(&self) -> Option<Retained<CLLocation>>
CLLocation only.pub unsafe fn headingAvailable(&self) -> bool
pub unsafe fn headingFilter(&self) -> CLLocationDegrees
CLLocation only.Sourcepub unsafe fn setHeadingFilter(&self, heading_filter: CLLocationDegrees)
Available on crate feature CLLocation only.
pub unsafe fn setHeadingFilter(&self, heading_filter: CLLocationDegrees)
CLLocation only.Setter for headingFilter.
pub unsafe fn headingOrientation(&self) -> CLDeviceOrientation
Sourcepub unsafe fn setHeadingOrientation(
&self,
heading_orientation: CLDeviceOrientation,
)
pub unsafe fn setHeadingOrientation( &self, heading_orientation: CLDeviceOrientation, )
Setter for headingOrientation.
pub unsafe fn heading(&self) -> Option<Retained<CLHeading>>
CLHeading only.pub unsafe fn maximumRegionMonitoringDistance(&self) -> CLLocationDistance
CLLocation only.pub unsafe fn monitoredRegions(&self) -> Retained<NSSet<CLRegion>>
CLRegion only.pub unsafe fn rangedRegions(&self) -> Retained<NSSet<CLRegion>>
CLRegion only.pub unsafe fn rangedBeaconConstraints( &self, ) -> Retained<NSSet<CLBeaconIdentityConstraint>>
CLBeaconIdentityCondition and CLBeaconIdentityConstraint and CLCondition only.pub unsafe fn requestWhenInUseAuthorization(&self)
pub unsafe fn requestAlwaysAuthorization(&self)
pub unsafe fn requestTemporaryFullAccuracyAuthorizationWithPurposeKey_completion( &self, purpose_key: &NSString, completion: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2 only.pub unsafe fn requestTemporaryFullAccuracyAuthorizationWithPurposeKey( &self, purpose_key: &NSString, )
pub unsafe fn startUpdatingLocation(&self)
pub unsafe fn stopUpdatingLocation(&self)
pub unsafe fn requestLocation(&self)
pub unsafe fn startUpdatingHeading(&self)
pub unsafe fn stopUpdatingHeading(&self)
pub unsafe fn dismissHeadingCalibrationDisplay(&self)
pub unsafe fn startMonitoringSignificantLocationChanges(&self)
pub unsafe fn stopMonitoringSignificantLocationChanges(&self)
pub unsafe fn startMonitoringLocationPushesWithCompletion( &self, completion: Option<&DynBlock<dyn Fn(*mut NSData, *mut NSError)>>, )
block2 only.pub unsafe fn stopMonitoringLocationPushes(&self)
pub unsafe fn startMonitoringForRegion_desiredAccuracy( &self, region: &CLRegion, accuracy: CLLocationAccuracy, )
CLLocation and CLRegion only.pub unsafe fn stopMonitoringForRegion(&self, region: &CLRegion)
CLRegion only.pub unsafe fn startMonitoringForRegion(&self, region: &CLRegion)
CLRegion only.pub unsafe fn requestStateForRegion(&self, region: &CLRegion)
CLRegion only.pub unsafe fn startRangingBeaconsInRegion(&self, region: &CLBeaconRegion)
CLBeaconRegion and CLRegion only.pub unsafe fn stopRangingBeaconsInRegion(&self, region: &CLBeaconRegion)
CLBeaconRegion and CLRegion only.pub unsafe fn startRangingBeaconsSatisfyingConstraint( &self, constraint: &CLBeaconIdentityConstraint, )
CLBeaconIdentityCondition and CLBeaconIdentityConstraint and CLCondition only.pub unsafe fn stopRangingBeaconsSatisfyingConstraint( &self, constraint: &CLBeaconIdentityConstraint, )
CLBeaconIdentityCondition and CLBeaconIdentityConstraint and CLCondition only.pub unsafe fn allowDeferredLocationUpdatesUntilTraveled_timeout( &self, distance: CLLocationDistance, timeout: NSTimeInterval, )
CLLocation only.pub unsafe fn disallowDeferredLocationUpdates(&self)
pub unsafe fn deferredLocationUpdatesAvailable() -> bool
pub unsafe fn requestHistoricalLocationsWithPurposeKey_sampleCount_completionHandler( &self, purpose_key: &NSString, sample_count: NSInteger, handler: &DynBlock<dyn Fn(NonNull<NSArray<CLLocation>>, *mut NSError)>, )
CLLocation and block2 only.Source§impl CLLocationManager
Methods declared on superclass NSObject.
impl CLLocationManager
Methods declared on superclass NSObject.
Source§impl CLLocationManager
CLVisitExtensions.
impl CLLocationManager
CLVisitExtensions.
pub unsafe fn startMonitoringVisits(&self)
CLLocationManager_CLVisitExtensions only.pub unsafe fn stopMonitoringVisits(&self)
CLLocationManager_CLVisitExtensions only.Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for CLLocationManager
impl AsRef<AnyObject> for CLLocationManager
Source§impl AsRef<CLLocationManager> for CLLocationManager
impl AsRef<CLLocationManager> for CLLocationManager
Source§impl AsRef<NSObject> for CLLocationManager
impl AsRef<NSObject> for CLLocationManager
Source§impl Borrow<AnyObject> for CLLocationManager
impl Borrow<AnyObject> for CLLocationManager
Source§impl Borrow<NSObject> for CLLocationManager
impl Borrow<NSObject> for CLLocationManager
Source§impl ClassType for CLLocationManager
impl ClassType for CLLocationManager
Source§const NAME: &'static str = "CLLocationManager"
const NAME: &'static str = "CLLocationManager"
Source§type ThreadKind = <<CLLocationManager as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<CLLocationManager as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for CLLocationManager
impl Debug for CLLocationManager
Source§impl Deref for CLLocationManager
impl Deref for CLLocationManager
Source§impl Hash for CLLocationManager
impl Hash for CLLocationManager
Source§impl Message for CLLocationManager
impl Message for CLLocationManager
Source§impl NSObjectProtocol for CLLocationManager
impl NSObjectProtocol for CLLocationManager
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref