I think that a different (better IMHO) approach is used here than a subclassification of CLLocationManager, for example in
http://code.google.com/p/dlocation/
In ObjectiveC, it seems possible to replace an existing method from a class without overriding it. This is often called the "swizzling method": you define your own category for an existing class, implement the existing method in it.
From the clientโs point of view, everything is transparent: he has a feeling that he is dealing with a real CLLocationManager , but in fact you โtook control from himโ . So he does not need to deal with any special subclass or any special delegation protocol: he continues to use the same class / protocol as the one from CoreLocation.
Here is an example to take control of the delegate that the client will enter:
@implementation CLLocationManager ()
- (void) setDelegate: (id) delegate { // setDelegate... } - (id) { // .... } - (void) startUpdatingLocation { } - (void) stopUpdatingLocation { } //.... // , CLLocationManager @
Then, in this implementation, you can deal with a predefined set of coordinates (coming from a file of any type) that will be โpushedโ to the delegate using the standard CLLocationManagerDelegate protocol.
yonel Jan 13 '10 at 21:12 2010-01-13 21:12
source share