【发布时间】:2014-09-01 22:40:08
【问题描述】:
这个问题是基于性能的,我得到了想要的结果。 我有一系列这样的字典:
Printing description of arrAppointmentDictionary:
<__NSArrayM 0x16f962a0>(
{
"component_id" = 159;
total = 1;
},
{
"component_id" = 165;
total = 1;
},
{
"component_id" = 177;
total = 1;
},
{
"component_id" = 191;
total = 1;
},
{
"component_id" = 193;
total = 1;
}
)
我根据这样的键在字典中搜索:
for (int i = 0; i<arrAppointmentDictionary.count; i++)
{
NSMutableDictionary *appointmentDictionary = [arrAppointmentDictionary objectAtIndex:i];
NSArray *keys = [appointmentDictionary allKeys];
for (NSString *key in keys)
{
@autoreleasepool {
NSLog(@"Key is %@", key);
if([[appointmentDictionary objectForKey: key] isEqualToString:[rs stringForColumn:@"id"]])
{
layout.numberOfAppointments = [appointmentDictionary objectForKey: @"total"];
NSLog(@"number of appointments are >>>>>>>>>>>>>>>>> %@", [appointmentDictionary objectForKey: @"total"]);
}
}
}
}
我得到准确的结果。 如何提高这个 for 循环的性能/内存优化,因为它是从另一个 while 循环调用的。
感谢和问候。
【问题讨论】:
标签: ios performance memory nsmutablearray nsmutabledictionary