/RHCoreLocationNotifier

Adds support to CLLocationManager for broadcasting location updates via NSNotification.

Primary LanguageObjective-COtherNOASSERTION

Core Location Notifier

RHCoreLocationNotifier generates and dispatches NSNotifications whenever a CLLocationManager in your application updates its delegate with new location information.

This is especially useful if you only wish to piggyback on updates generated by other location updating code.

How does it work?

RHCoreLocationNotifier works by injected a proxy class between CLLocationManager and its delegate, invisibly forwarding all delegate method calls onwards, while at the same time siphoning any CLLocation objects 'from the wire' as they pass through.

RHCoreLocationNotifierLocationChangedNotifications are dispatched for all initialized CLLocationManager instances automatically, and there is no setup required.

Usage

Using RHCoreLocationNotifier is super simple, just register for notifications and you are good to go.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_locationUpdatedNotification:) name:RHCoreLocationNotifierLocationChangedNotification object:nil];
...


-(void)_locationUpdatedNotification:(NSNotification *)notification{
    dispatch_async(dispatch_get_main_queue(), ^{
        NSArray *locations = [notification.userInfo objectForKey:RHCoreLocationNotifierAllLocationsKey];
        //do your thing
    });
}

Licence

Released under the Modified BSD License. (Attribution Required)

Copyright (c) 2014 Richard Heard. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Version Support

RHCoreLocationNotifier has been tested on iOS 7 and OS X 10.9 and it should support all currently used system architectures (including arm64). It should also work fine with older OS versions.

You Be Social?

If so, you can follow me on Twitter! (@heardrwt)