NAZIK NAZIK - 1 year ago 90
iOS Question

Issues in getting directions in mkmapview

I'm working with getting directions in

, I got code from this answer.

In the function

- (NSArray*)getRoutePointFrom:(Annotation *)origin to:(Annotation *)destination
NSString* saddr = [NSString stringWithFormat:@"%f,%f", origin.coordinate.latitude, origin.coordinate.longitude];
NSString* daddr = [NSString stringWithFormat:@"%f,%f", destination.coordinate.latitude, destination.coordinate.longitude];

NSString* apiUrlStr = [NSString stringWithFormat:@"", saddr, daddr];
NSURL* apiUrl = [NSURL URLWithString:apiUrlStr];

NSError *error;
NSString *apiResponse = [NSString stringWithContentsOfURL:apiUrl encoding:NSUTF8StringEncoding error:&error];
NSString* encodedPoints = [apiResponse stringByMatching:@"points:\\\"([^\\\"]*)\\\"" capture:1L];

return [self decodePolyLine:[encodedPoints mutableCopy]];

I got some small issues, searched for solutions, but I can't.

The issues are

1.Parse Issue

Expected a type


- (NSArray*)getRoutePointFrom:(Annotation *)origin to:(Annotation *)destination

2.Automatic Reference counting issue

'NSString' for instance message does not declare a method with selector 'stringByMatching:capture:'


NSString* encodedPoints = [apiResponse stringByMatching:@"points:\\\"([^\\\"]*)\\\"" capture:1L];

How to solve these two issues?

Answer Source

In addition to Robotic Cat's answer, try to do following:

  1. Goto: This Project (As, I got that from there)
  2. Open the enclosing folder
  3. Find RegexKitLite Folder in it.
  4. Add it to your project (with copy file to destination group AND Add to target options enabled)
  5. Add #import RegexKitLite.h to your .m file.

Most probably the problem will be solved.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download