Firtsly hi to everyone,
I'm very new in Objective C programming,
Let's start my question...
I have method (function) which returns an array, and with this array i want to fill another array in where i want to use.
here are the my codes.
in this example i use it for a button when i press it creates number then showme.
my function which name is myNumbers creates random 6 numbers 1 to 49, then put them in an array and send it.
the red one which is my new array I want to fill it from myNumbers method. However i cant do it.
Thanks for all helps.
I'm very new in Objective C programming,
Let's start my question...
I have method (function) which returns an array, and with this array i want to fill another array in where i want to use.
here are the my codes.
in this example i use it for a button when i press it creates number then showme.
my function which name is myNumbers creates random 6 numbers 1 to 49, then put them in an array and send it.
Code:
+(NSArray*)myNumbers{
int tamammi=0;
//static int gonder[6];
NSArray *gonder = [[NSArray alloc]init];
int sayac=0;
while(1)
{
if (sayac < 6){
int rnd=rand()%49+1;
int z;
int varmi=0;
for (z=0;z<6;z++){
if ([gonder objectAtIndex:z]==rnd){
varmi=1;
break;
}
}
if (varmi==0){
[gonder addObject:[NSNumber numberWithInt:rnd]];
//gonder[sayac]=rnd;
sayac += 1;
}
}else tamammi=1;
if (tamammi==1){
break;
}
}
return gonder;
}
in the main section i want to fill another array by calling this method.
testViewController *me=[testViewController new];
[COLOR="Red"]NSArray *sayilar =[[NSArray alloc]initWithArray:[me myNumbers]];[/COLOR]
[me release;]
the red one which is my new array I want to fill it from myNumbers method. However i cant do it.
Thanks for all helps.