简体   繁体   中英

How to store integer value into an array in iPhone?

My mutableArray is

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.... 

I want to convert these value into integer format and store it another array. For this I am doing this:

int currentNumber;
for(int i=0; i<[dayArray count]; i++)
{
    currentNumber = [((NSNumber*)[dayArray objectAtIndex:i]) intValue];

}
NSLog(@"currentNumber is : %d",currentNumber);

currentNumber print 10,15,26,28 but I want to store it into array having integer format. These are day and I want to show these day into calendar with highlighted red color

Why don't just pass dayArrayDirectly? It is already have NSNumber Objects into it.

尝试这个

[dictionaryArray setObject:[NSNumber numberWithInt:1] forKey:@"ANumberValue"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM