/ / Come utilizzare SDURLCache e AFNetworking - ios, afnetworking

Come utilizzare SDURLCache e AFNetworking - ios, afnetworking

Sono principiante. Ho un problema con il codice SDURLCache e AFNetwoking.my:

per prima cosa ho impostato sdurlcache nel mio appdelegate.m

self.cache = [[SDURLCache alloc] initWithMemoryCapacity:1024*1024 // 1 MB mem cache
diskCapacity:1024*1024*5 // 5 MB disk cache
diskPath:[SDURLCache defaultCachePath]];
self.cache.ignoreMemoryOnlyStoragePolicy = YES;
[NSURLCache setSharedURLCache:self.cache];

secondo, ho usato AFNetwoking + UIImageView nel mio tableCell:

 [cell.Image setImageWithURL:url placeholderImage:[UIImage imageNamed:@"zhanweiSmall.png"]];

Ma la foto non è cache. Se la rete non è valida, la foto non viene mostrata

risposte:

0 per risposta № 1

Se si utilizza IOS5 o superiore, NSURLCache salva automaticamente le risposte sul disco. Quindi non hai bisogno di SDURLCache. Vedi il post sul blog di Peter per maggiori informazioni.

http://petersteinberger.com/blog/2012/nsurlcache-uses-a-disk-cache-as-of-ios5/