I'm working with getting directions in mkmapview
, 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:@"http://maps.google.com/maps?output=dragdir&saddr=%@&daddr=%@", 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
in
- (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:'
in
NSString* encodedPoints = [apiResponse stringByMatching:@"points:\\\"([^\\\"]*)\\\"" capture:1L];
How to solve these two issues?
In addition to Robotic Cat's answer, try to do following:
RegexKitLite
Folder in it.copy file to destination group
AND
Add to target
options enabled)#import RegexKitLite.h
to your .m
file.Most probably the problem will be solved.