iphone - getDistanceFrom Vs distanceFromLocation -


I'm having trouble with trouble. I GetDistanceFrom iOS 4.1 is hijacked and is not available in distanceFromLocation 3.1.3, I How do I get the problem?

Has anyone else come in this problem?

Currently my code is:

  CLLocationDistance kilometers; If ([Responds to current location Tilakritta: @selector (distance_follow location :)) {kilometers = [location from current location distance: last location] / 1000; } And {// kilometers = [get current location special: previous location] / 1000; Kilometers = [Select current location Selector: @Selector (gate distance format :) with object: previous location] / 1000; }  

Based on the compilation of iOS, I am receiving 'illegal operations for binary' on lines:

  kilometers = [current location Distance from location: last location] / 1000; Kilometers = [Select current location Selector: @Selector (gate distance format :) with object: previous location] / 1000;  

Regards, Stephen

There is a Cedric Looty There is a very good solution.

In short, you need to enter the following in your main.m and make sure that #import & lt; Objc / runtime.h & gt; :

method getDistanceFrom = class_getInstanceMethod ([CLLocation class], @selector (getDistanceFrom :)); Class_addMethod ([CLLocation class], @selector (distanceFromLocation :), method_getDistanceFrom, method_getTypeEncoding (getDistanceFrom));

You can then use distanceFromLocation: on any OS.


Comments