我有一个plist,它是一个10索引的数组;这是第一次正确读取,现在我从plist数组中删除了一些或者5个最后一个索引形式plist xml,在获取之后它仍将返回10个索引的数组,而现在它应该返回5个索引的数组,是否来自缓存。我怎么能解决这个??? 这就是我通过调用这个来读取plist数据的方法: -
NSArray *plistDataArray = [self GetSavedPlistDatawithPlistIdentifier:myPlistName];
功能是: -
-(NSMutableArray*)GetSavedPlistDatawithPlistIdentifier :(NSString*)plistfilename {
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *plistPath = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.plist",plistfilename]];
if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath])
{
plistPath = [[NSBundle mainBundle] pathForResource:plistfilename ofType:@"plist"];
}
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSString *errorDesc = nil;
NSPropertyListFormat format;
NSMutableArray *tempfeedBackArr =(NSMutableArray *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
return tempfeedBackArr;
}
答案 0 :(得分:0)
关于你的问题和评论的某些内容并不合理。您发布的代码是从文档目录中读取的,该目录是运行时目录。然后你说你不写它。
文档目录在应用程序运行期间写入,并在更新之间保留。如果您构建并运行新版本的应用程序,它仍将在文档目录中包含相同的内容。