ios - confusion in data storage into nscache -


i know im doing mistake here coz cant run project im trying build , im trying here parsed data xml save nsdata , put data cache when run project doesnt load data.

@implementation viewcontroller {         nscache *mycache;     }   - (void)viewdidload {         mycache = [[nscache alloc] init]; }  //saving data cache nsstring *imageurl = [currentdata.imagelink]; nsurl *url = [nsurl urlwithstring:imageurl]; nsdata *data = [nsdata datawithcontentsofurl:url]; data = [imagescache objectforkey:@"key"]; [imagescache setobject:imagelinks forkey:@"key"]; 

a few things:

  1. data downloads should done on background thread.
  2. it's best have own object in cache, , object should download image , cache both image , save image disk. when cache gets purged should remove image , reload disk if required.
  3. this code:

    nsdata *data = [nsdata datawithcontentsofurl:url]; data = [imagescache objectforkey:@"key"]; [imagescache setobject:[nsdata datawithcontentsofurl:url] forkey:@"key"]; 

downloads date, throws away , replaces whatever in cache , updates cache else. should more like:

[imagescache setobject:imagelinks forkey:@"key"]; 

for point 2 objects should confirm nsdiscardablecontent.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -