CLRegion Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/CoreLocation.framework
Availability
Available in OS X v10.7 and later.
Companion guide
Declared in
CLRegion.h

Overview

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.

Tasks

Initializing a Region in OS X

Accessing a Region’s Attributes

Hit Testing in a Region

Properties

center

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

@property(readonly, nonatomic) CLLocationCoordinate2D center
Special Considerations

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

Availability
  • Available in OS X v10.7 and later.
Declared In
CLRegion.h

identifier

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

@property(readonly, nonatomic) NSString *identifier
Discussion

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

Availability
  • Available in OS X v10.7 and later.
Declared In
CLRegion.h

radius

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

@property(readonly, nonatomic) CLLocationDistance radius
Special Considerations

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

Availability
  • Available in OS X v10.7 and later.
Declared In
CLRegion.h

Instance Methods

containsCoordinate:

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

- (BOOL)containsCoordinate:(CLLocationCoordinate2D)coordinate
Parameters
coordinate

The coordinate to test against the region.

Return Value

YES if the coordinate lies within the region’s boundaries or NO if it does not.

Special Considerations

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

Availability
  • Available in OS X v10.7 and later.
Declared In
CLRegion.h

initCircularRegionWithCenter:radius:identifier:

Initializes and returns a region object defining a circular area.

- (id)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.

Availability
  • Available in OS X v10.7 and later.
Declared In
CLRegion.h