Authored by Thomas Rasch

Merge pull request #25 from incanus/better_tile_notifications

better tile notifications on main queue & with tile reference hashes
... ... @@ -61,7 +61,10 @@
if (image)
return image;
[[NSNotificationCenter defaultCenter] postNotificationName:RMTileRequested object:nil];
dispatch_async(dispatch_get_main_queue(), ^(void)
{
[[NSNotificationCenter defaultCenter] postNotificationName:RMTileRequested object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]];
});
[tileCache retain];
... ... @@ -93,12 +96,12 @@
if (tileData)
{
dispatch_sync(dispatch_get_main_queue(), ^(void)
@synchronized(self)
{
// safely put into collection array in proper order
//
[tilesData replaceObjectAtIndex:u withObject:tileData];
});
};
}
});
}
... ... @@ -135,7 +138,10 @@
[tileCache release];
[[NSNotificationCenter defaultCenter] postNotificationName:RMTileRetrieved object:nil];
dispatch_async(dispatch_get_main_queue(), ^(void)
{
[[NSNotificationCenter defaultCenter] postNotificationName:RMTileRetrieved object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]];
});
if (!image)
return [RMTileImage errorTile];
... ...
... ... @@ -96,6 +96,11 @@
NSInteger x = tile.x;
NSInteger y = pow(2, zoom) - tile.y - 1;
dispatch_async(dispatch_get_main_queue(), ^(void)
{
[[NSNotificationCenter defaultCenter] postNotificationName:RMTileRequested object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]];
});
__block UIImage *image;
[queue inDatabase:^(FMDatabase *db)
... ... @@ -120,6 +125,11 @@
[results close];
}];
dispatch_async(dispatch_get_main_queue(), ^(void)
{
[[NSNotificationCenter defaultCenter] postNotificationName:RMTileRetrieved object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]];
});
return image;
}
... ...