Mac Developer Library

Developer

CoreLocation Framework Reference CLRegion Class Reference

Options
Deployment Target:

On This Page
Language:

CLRegion

The CLRegion class defines an abstract area that can be tracked. In iOS, you do not create instances of this class directly; instead, you instantiate subclasses that define specific types of regions. In OS X, you create instances of this class and use them to store the region information. After you create a region, you must register it with a CLLocationManager object. The location manager generates appropriate events whenever the user crosses the boundaries of the region. More...

Inheritance


Import Statement


import CoreLocation @import CoreLocation;

Availability


Available in OS X v10.7 and later.
  • Initializes and returns a region object defining a circular area.

    Declaration

    Swift

    init!(circularRegionWithCenter center: CLLocationCoordinate2D, radius radius: CLLocationDistance, identifier identifier: String!)

    Objective-C

    - (instancetype)initCircularRegionWithCenter:(CLLocationCoordinate2D)center radius:(CLLocationDistance)radius identifier:(NSString *)identifier

    Parameters

    center

    The center point of the region.

    radius

    The distance (measured in meters) from the center point that marks the boundary of the region.

    identifier

    A unique identifier to associate with the region object. You use this identifier to differentiate regions within your application. This value must not be nil.

    Return Value

    An initialized region object.

    Special Considerations

    In iOS, use a CLCircularRegion object to manage geographic regions.

    Import Statement

    import CoreLocation

    Availability

    Available in OS X v10.7 and later.

    Deprecated in OS X v10.10.

  • The identifier for the region object. (read-only)

    Declaration

    Swift

    var identifier: String! { get }

    Objective-C

    @property(readonly, nonatomic, copy) NSString *identifier

    Discussion

    This is a value that you specify and can use to identify this region inside your application.

    Import Statement

    import CoreLocation

    Availability

    Available in OS X v10.7 and later.

  • center center (OS X v10.10) Property

    The center point of the region. (read-only)

    Declaration

    Swift

    var center: CLLocationCoordinate2D { get }

    Objective-C

    @property(readonly, nonatomic) CLLocationCoordinate2D center

    Special Considerations

    In iOS, use a CLCircularRegion object to manage geographic regions.

    Import Statement

    import CoreLocation

    Availability

    Available in OS X v10.7 and later.

    Deprecated in OS X v10.10.

  • radius radius (OS X v10.10) Property

    The radius (measured in meters) that defines the region’s outer boundary. (read-only)

    Declaration

    Swift

    var radius: CLLocationDistance { get }

    Objective-C

    @property(readonly, nonatomic) CLLocationDistance radius

    Special Considerations

    In iOS, use a CLCircularRegion object to manage geographic regions.

    Import Statement

    import CoreLocation

    Availability

    Available in OS X v10.7 and later.

    Deprecated in OS X v10.10.

  • A Boolean indicating that notifications are generated upon entry into the region.

    Declaration

    Swift

    var notifyOnEntry: Bool

    Objective-C

    @property(nonatomic, assign) BOOL notifyOnEntry

    Discussion

    When this property is YEStrue, a device crossing from outside the region to inside the region triggers the delivery of a notification. If the property is NOfalse, a notification is not generated. The default value of this property is YEStrue.

    If the app is not running when a boundary crossing occurs, the system launches the app into the background to handle it. Upon launch, your app must configure new location manager and delegate objects to receive the notification. The notification is sent to your delegate’s locationManager:didEnterRegion: method.

    Import Statement

    import CoreLocation

    Availability

    Available in OS X v10.10 and later.

  • A Boolean indicating that notifications are generated upon exit from the region.

    Declaration

    Swift

    var notifyOnExit: Bool

    Objective-C

    @property(nonatomic, assign) BOOL notifyOnExit

    Discussion

    When this property is YEStrue, a device crossing from inside the region to outside the region triggers the delivery of a notification. If the property is NOfalse, a notification is not generated. The default value of this property is YEStrue.

    If the app is not running when a boundary crossing occurs, the system launches the app into the background to handle it. Upon launch, your app must configure new location manager and delegate objects to receive the notification. The notification is sent to your delegate’s locationManager:didExitRegion: method.

    Import Statement

    import CoreLocation

    Availability

    Available in OS X v10.10 and later.

  • Returns a Boolean value indicating whether the region contains the specified coordinate.

    Declaration

    Swift

    func containsCoordinate(_ coordinate: CLLocationCoordinate2D) -> Bool

    Objective-C

    - (BOOL)containsCoordinate:(CLLocationCoordinate2D)coordinate

    Parameters

    coordinate

    The coordinate to test against the region.

    Return Value

    YEStrue if the coordinate lies within the region’s boundaries or NOfalse if it does not.

    Special Considerations

    In iOS, use a CLCircularRegion object to manage geographic regions.

    Import Statement

    import CoreLocation

    Availability

    Available in OS X v10.7 and later.

    Deprecated in OS X v10.10.

  • Constants that reflect the relationship of the current location to the region boundaries.

    Declaration

    Swift

    enum CLRegionState : Int { case Unknown case Inside case Outside }

    Objective-C

    typedef { CLRegionStateUnknown, CLRegionStateInside, CLRegionStateOutside } CLRegionState;

    Constants

    • Unknown

      CLRegionStateUnknown

      It is unknown whether the location is inside or outside of the region.

      Available in OS X v10.10 and later.

    • Inside

      CLRegionStateInside

      The location is inside the given region.

      Available in OS X v10.10 and later.

    • Outside

      CLRegionStateOutside

      The location is outside of the given region.

      Available in OS X v10.10 and later.

    Import Statement

    import CoreLocation

    Availability

    Available in OS X v10.10 and later.