我从服务器使用NSURLConnection检索pList,由我写的一些php生成的。我的Plist在根级别包含几个数组。这些数组包含服务器NSDictionyObjects。一旦我检索到pList,我使用NSPropertyLitSerialization将数据序列化成一个NSDictionary。NSDictionary vs自定义对象的性能
现在,一旦我有了这个NSDictionary,我将这些值加载到我用下面的代码创建的自定义对象中。
NSMutableDictionary *newDict = [[NSMutableDictionary alloc]init];
//Create object array.
for (NSString *key in dict) {
NSArray *tempArr = [dict objectForKey:key];
NSMutableArray *gameObjectArray = [[NSMutableArray alloc]
initWithCapacity:tempArr.count];
for (NSDictionary *tempDict in tempArr) {
//Build Objects and add to array
GameObject *tempGame = [[GameObject alloc] initWithArr:tempDict];
//initWithArr initializes the values in the object using tempDict
[gameObjectArray addObject:tempGame];
[tempGame release];
}
[newDict setObject:gameObjectArray forKey:key];
[gameObjectArray release];
}
self.gameObjectsDict = newDict;
从现在开始,我在整个应用程序中使用存储gameObjectsDict的值对象。适用于各种类型的东西,包括呈现UITableViews和将数据传递给其他viewControllers/views。
我的问题: 是否值得将我的pList中的所有值放入值对象?
之前,我只是使用NSDictionary传递我的价值观周围的应用程序,它工作正常。我觉得编写代码和使用值对象更好的做法会更容易,但是现在使用值对象的Im感觉像是在浪费更多的内存。感觉就像我将这些沉重的物体放在哪里,像以前一样,我只是在需要时从字典中获取值。