R
R
Ruslan Bergutov2015-12-25 07:36:13
Objective-C
Ruslan Bergutov, 2015-12-25 07:36:13

Why is map caching not working?

- (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:;

    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:;
            result(data, error);
        }] resume];
    }
}

for some reason the cache is not being captured

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question