iOS Developer Library

Developer

CoreLocation Framework Reference CLRegion Class Reference

Options
Deployment Target:

On This Page
Language:

CLRegion

Inherits From


Conforms To


Import Statement


Swift

import CoreLocation

Objective-C

@import CoreLocation;

Availability


Available in iOS 4.0 and later

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.

To use this class, create an instance of it and use the startMonitoringForRegion: method of a CLLocationManager object to begin monitoring it.

  • Initializes and returns a region object defining a circular area.

    Declaration

    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

    Objective-C

    @import CoreLocation;

    Availability

    Available in iOS 4.0 and later

    Deprecated in iOS 7.0

  • 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

    Objective-C

    @import CoreLocation;

    Swift

    import CoreLocation

    Availability

    Available in iOS 4.0 and later

  • center center (iOS 7.0) Property

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

    Declaration

    Objective-C

    @property(readonly, nonatomic) CLLocationCoordinate2D center

    Special Considerations

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

    Import Statement

    Objective-C

    @import CoreLocation;

    Availability

    Available in iOS 4.0 and later

    Deprecated in iOS 7.0

  • radius radius (iOS 7.0) Property

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

    Declaration

    Objective-C

    @property(readonly, nonatomic) CLLocationDistance radius

    Special Considerations

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

    Import Statement

    Objective-C

    @import CoreLocation;

    Availability

    Available in iOS 4.0 and later

    Deprecated in iOS 7.0

  • 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

    Objective-C

    @import CoreLocation;

    Swift

    import CoreLocation

    Availability

    Available in iOS 7.0 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

    Objective-C

    @import CoreLocation;

    Swift

    import CoreLocation

    Availability

    Available in iOS 7.0 and later

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

    Declaration

    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

    Objective-C

    @import CoreLocation;

    Availability

    Available in iOS 4.0 and later

    Deprecated in iOS 7.0

  • 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 iOS 7.0 and later

    • Inside

      CLRegionStateInside

      The location is inside the given region.

      Available in iOS 7.0 and later

    • Outside

      CLRegionStateOutside

      The location is outside of the given region.

      Available in iOS 7.0 and later

    Import Statement

    Objective-C

    @import CoreLocation;

    Swift

    import CoreLocation

    Availability

    Available in iOS 7.0 and later