/ / Cómo usar SDURLCache y AFNetworking - ios, afnetworking

Cómo usar SDURLCache y AFNetworking - ios, afnetworking

i "m beginner.i tengo un problema sobre SDURLCache y AFNetwoking.my code:

primero, estoy configurando sdurlcache en mi 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];

segundo, usé AFNetwoking + UIImageView en mi tablaCell:

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

Pero la imagen no es caché. Si la red no es válida, la imagen no se muestra.

Respuestas

0 para la respuesta № 1

Si está utilizando IOS5 o superior, NSURLCache guarda automáticamente las respuestas en el disco. Así que no necesitas SDURLCache. Consulta la publicación del blog de Peter para obtener más información.

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