0
我想緩存一些https請求的結果來加速用戶界面,所以我想緩存applicationWillResignActive中的數據:並將它恢復到didFinishLaunchingWithOptions中。 爲此,我使用以下代碼片段: NSArray * paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES);NSMutableArray緩存失敗
NSString* cachesDirectory=[paths objectAtIndex:0];
NSString* archivePath=[cachesDirectory stringByAppendingPathComponent:@"AppCache/Paline.archive"];
NSLog(@"archivePath=%@ paline=%@", archivePath, detailViewController.palineArray);
BOOL success=[NSKeyedArchiver archiveRootObject:detailViewController.palineArray toFile:archivePath];
NSLog(@"%@",[email protected]"success": @"failure");
失敗和返回nil在還原時與:
NSMutableArray* cachedItems=[NSKeyedUnarchiver unarchiveObjectWithFile:archivePath];
NSLog(@"archivePath=%@ cache=%@", archivePath, cachedItems);
的palineArray是一個NSMutableArray與值,系列化當如由先前的NSLog。 它可能是什麼?它不符合NSMutableArray編碼或什麼?
感謝, 法布里奇奧