我有一个数组NSMutableArray
。它包含XML文件中的对象 - @"time"
。我需要将所有记录从NSMutableArray
移动到密钥@"time"
到NSArray
。这是为了根据日历上的日期突出显示标记。我该如何实施呢?
如果我写代码:
NSDictionary *nItem = [rasp objectAtIndex:0]; //here instead of 0, you should put the number of elements in the array, but I do not get ((
NSArray *data = [NSArray arrayWithObjects:[nItem objectForKey:@"time"], nil];
NSMutableArray
仅从数组中分配第一个日期,索引为0.
答案 0 :(得分:0)
你可以这样做。
NSMutableArray* mutable = [NSMutableArray arrayWithCapacity:0];
for(NSDictionary* nItem in rasp)
{
[mutable addObject:[nItem objectForKey:@"time"]];
}
NSArray *data = [NSArray arrayWithArray:mutable];
希望它有所帮助!