[英]How to store integer value into an array in iPhone?
我的mutableArray是
NSDictionary *dict;
self.dayArray = [[NSMutableArray alloc] initWithCapacity:[xmlParseArray count]];
for(dict in xmlParseArray)
if([dict objectForKey:@"day"])
[self.dayArray addObject:[dict objectForKey:@"day"]];
NSLog(@"dayArray is : %@",dayArray);
dayArray print : 10,15,26,28....
我想將這些值轉換為整數格式並將其存儲在另一個數組中。 為此,我正在這樣做:
int currentNumber;
for(int i=0; i<[dayArray count]; i++)
{
currentNumber = [((NSNumber*)[dayArray objectAtIndex:i]) intValue];
}
NSLog(@"currentNumber is : %d",currentNumber);
currentNumber打印10、15、26、28,但我想將其存儲到具有整數格式的數組中。 這是一天,我想將這些天顯示在日歷上,並突出顯示紅色
為什么不僅僅通過dayArrayDirectly? 它已經有NSNumber對象了。
嘗試這個
[dictionaryArray setObject:[NSNumber numberWithInt:1] forKey:@"ANumberValue"];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.