iPhone:How to make an integer array and store values in Obj-C?
- by user187532
Hi,
I want to know a simple thing, which i couldn't get it is that i want to store 10 values in an integer array dynamically and then i have to check that stored values and compared with the current values whether it is same or not in some other condition. Initially i tried same like C array, int temp[10], but seems to be that is not possible to set and get method, then i tried NSNumber like below,
In AppDelagate file,
NSMutableArray *reqID;
@property (nonatomic,readwrite)
NSMutableArray * reqID;
@synthesize reqID;
........................
........................
........................
In Some other file,
int rd = (1+arc4random() % [arr count]);
[myDelagate.reqID addObject:[NSNumber numberWithUnsignedInteger:rd]];
then i need to check,
for (int i=0; i<10; i++)
{
NSUInteger anInt = [[amyDelagate.reqID objectAtIndex:i] unsignedIntegerValue];
if ( anInt==rd )
{
rd = (1+arc4random() % [arr count]);
break;
}
}
[myDelagate.reqID addObject:[NSNumber numberWithUnsignedInteger:rd]];
But it doesn' work as expected, i.e array value doesn't give proper value. i don't know how to use integer array in Obj-C and handle it to access later etc.
Could someone please explian me?