I have the below method and I want to call it and return the array data in another method but that does not work. but the self in the other method returns no data?
- (NSMutableArray *)glo
{
NSMutableArray *globalarray = [[NSMutableArray array]init];
for (int x = 0; x < 10; x++) {
[globalarray addObject: [NSNumber numberWithInt: arc4random()%200]];
return globalarray ;
}
}
-(IBAction)clicked_insertsort:(id)sender{
[self glo];
}
I really try to replace some part in your code to something like this:
and this:
UPDATE:
if you want a global variable in you class you should define the following:
and the methods will be the following (no return value needed, because the variable is available from the whole class now)