質問

I working on map app and consider to using new function in iOS7 for MKTileOverlay and MKTileOverlayRenderer. But I googled around with no luck.

I found this thread, tell me to do subclassing MKTileOverlay

Hiding mapview when mapoverlay is visible ios7

Code from thread:

-(void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result
{
    NSData *tile = [self someHowGetTileImageIntoNSDataBaseOnPath:path];
    if (tile) {
        result(tile, nil);
    } else {
        result(nil, [NSError errorWithDomain: CUSTOM_ERROR_DOMAIN code: 1 userInfo:nil]);
    }
}

Question is: [self someHowGetTileImageIntoNSDataBaseOnPath:path] is load tileData But How can I save tileData to DB?

And if I can get tileData from Database result(tile, nil); is enough for make overlay show up? Or I need to do something else after overwrite loadTileAtPath:result:

Thank you

役に立ちましたか?

解決

I sorry for asking stupid question, Now I think I understand more about this MKTileOverlay.

-(void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result
{
    NSData *tile = [self someHowGetTileImageIntoNSDataBaseOnPath:path];
    if (tile) {
        result(tile, nil);
    } else {
        NSHTTPURLResponse *response = nil;
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self URLForTilePath:path]];
        //Or you can using asynchronous request.
        NSData *tileData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
        [self saveCachedWithData:tileData];
        result(tileData, nil);
    }
}

May be looking around for a day make me stun and cannot understand it's library, Sorry again and hope this may help someone who face same problem.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top