- (NSURL *)URLForTilePath:(MKTileOverlayPath)path {
return [NSURL URLWithString:[NSString stringWithFormat:@"http://tile.site.ru/%d/%d/%d.png", path.z, path.x, path.y]];
}
- (void)loadTileAtPath:(MKTileOverlayPath)path
result:(void (^)(NSData *data, NSError *error))result
{
if (!result) {
return;
}
NSData *cachedData = [self.tileCache objectForKey:[[self URLForTilePath:path] absoluteString]];
if (cachedData) {
NSLog(@"Self Tile Cache Data: %@", cachedData);
result(cachedData, nil);
} else {
NSURLRequest *request = [NSURLRequest requestWithURL:[self URLForTilePath:path]];
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
[self.tileCache setObject:data forKey:[[self URLForTilePath:path] absoluteString]];
result(data, error);
}] resume];
}
}
по какой то причине не происходит захват кеша