- (void)saveClassData:(NSMutableArray *)array { if ([array count] > 0) { NSMutableArray * classArray = nil; //獲取分類的沙盒文件路徑 NSArray* myPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* myDocPath = [myPaths objectAtIndex:0]; NSString* path = [myDocPath stringByAppendingPathComponent:@「info.plist」]; //解歸檔該路徑下的文件 classArray = [NSKeyedUnarchiver unarchiveObjectWithFile:path]; if (classArray == nil) { classArray = [[[NSMutableArray alloc] init] autorelease]; } [classArray removeAllObjects]; [classArray addObjectsFromArray:array]; // PPRSLog(@"歸檔前classArray : %@", classArray); //將數據歸檔,若是前面的文件不存在,就會在歸檔數據時建立 [NSKeyedArchiver archiveRootObject:classArray toFile:path]; }; }