GithubHelp home page GithubHelp logo

gultekingokhan / cllocationmanager-blocks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from axldyb/cllocationmanager-blocks

0.0 2.0 0.0 233 KB

A category on CLLocationManager adding blocks. Also some new features.

License: MIT License

cllocationmanager-blocks's Introduction

#CLLocationManager-blocks A category on CLLocationManager adding blocks plus some new functionality.

Installation

CLLocationManager-block is available through CocoaPods, to install it simply add the following line to your Podfile:

pod 'CLLocationManager-blocks'

##Usage This category provides location updates in two ways.

  • Custom update block
  • Block implementation of the basic CLLocationManagerDelegate methods

##Custom block for recieving updates Recieving location updates in a block.

self.manager = [[CLLocationManager alloc] init]; 
[self.manager startUpdatingLocationWithUpdateBlock:^(CLLocationManager *manager, CLLocation *location, NSError *error, BOOL *stopUpdating) {
    NSLog(@"Our new location: %@", location);
}]; 

NOTE: Location updates will start automatically by calling this method. No need to call startUpdatingLocation.

By using this block you will get the location updates without using the delegate methods. The underlying method locationManager:didUpdateLocations:does provide updates in an array, but we spilt them up into single updates in the block.

If the update is unsuccessful an error will be provided and location will be nil. If success the error will be nil and location will be an CLLocation object.

You can set the stopUpdating boolean to YES stop location updates at any successful or unsuccessful update.

*stopUpdating = YES; 

##Additional parameters

In addition to the blocks two new parameters are added

####updateAccuracyFilter

The standard [CLLocationManager desiredAccuracy] cannot garantie that the provided accuracy requrements are meet. By setting this parameter all updates with a higher inaccuracy than specified are excluded.

  • Unless you are running updates for a long period, set the [CLLocationManager desiredAccuracy] to kCLLocationAccuracyBest and your desired updateAccuracyFilter specified in meters.
  • updateAccuracyFilter is used for all blocks.
  • Default is set to kCLUpdateAccuracyFilterNone.

####updateLocationAgeFilter This parameter is set to filter out location updates older than the specified value in seconds. CLLocationManager location updates may provide old updates for different reasons and this is a good way to get a fresh plot.

  • Default is set to kCLLocationAgeFilterNone

####Example

self.manager.updateAccuracyFilter = 50.0;
self.manager.updateLocationAgeFilter = 15.0;

##Blocks

The category contains block implementations of the basic CLLocationManagerDelegate methods

NOTE: Unlike the startUpdatingLocationWithUpdateBlock: you will have to call startUpdatingLocation to recieve updates.

locationManager:didUpdateLocations:

[self.manager didUpdateLocationsWithBlock:^(CLLocationManager *manager, NSArray *locations) {
	// Did update locations
}];

locationManager:didChangeAuthorizationStatus:

[self.manager didChangeAuthorizationStatusWithBlock:^(CLLocationManager *manager, CLAuthorizationStatus status) { 
	// Did change authorization status       
}];

locationManager:didEnterRegion:

[self.manager didEnterRegionWithBlock:^(CLLocationManager *manager, CLRegion *region) {
	// Did enter region
}]

locationManager:didExitRegion:

[self.manager didExitRegionWithBlock:^(CLLocationManager *manager, CLRegion *region) {
	// Did exit region       
}]

locationManager:monitoringDidFailForRegion:

[self.manager monitoringDidFailForRegionWithBlock:^(CLLocationManager *manager, CLRegion *region, NSError *error) {
	// Monitoring did fail for region        
}]

locationManager:didStartMonitoringForRegion:

[self.manager didStartMonitoringForRegionWithBlock:^(CLLocationManager *manager, CLRegion *region) {
	// Did start monitoring for region        
}]

##Convenience methods Method to ease the steps to state if location updates is authorized by the user.

isLocationUpdatesAvailable


if ([CLLocationManager isLocationUpdatesAvailable]) {
	// Location updates authorized
}

##License

See the LICENSE file

© 2013 Aksel Dybdal

cllocationmanager-blocks's People

Contributors

jeddison avatar mrakowski avatar

Watchers

James Cloos avatar Gokhan Gultekin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.