mapbox/mbxmapkit — pull request #23 by wsnook (2014-01-22 05:41:31+00:00)
Title: Fix for #22: Only write to cache for an HTTP 200, sweep empty png files.

This addresses issue #22 where empty PNG files were getting written to cache for tiles which failed to load while the app was running in airplane mode. There are two parts to the change:
1) For tiles that aren't in the cache, `loadTileAtPath:result:` now takes a closer look at the type of response generated by the tile request. Anything other than an HTTP 200 is treated as an error (i.e. don't write file to cache, call `result(data,error)` with nil data and an NSError describing the problem).
2) sweepCache now deletes any cached images which have a size of 0 bytes. For devices with an existing cache folder, this should clean up any debris which may have been created by the old `loadTileAtPath:result:` code.