Hi I want to put this into a function.
NSMutableArray* weekArray = [[NSMutableArray alloc] init];
[weekArray addObject:@"Before School"];
[weekArray addObject:[NSString stringWithFormat:@""]];
[weekArray addObject:[NSString stringWithFormat:@""]];
[weekArray addObject:@"Break"];
[weekArray addObject:[NSString stringWithFormat:@""]];
[weekArray addObject:[NSString stringWithFormat:@""]];
开发者_StackOverflow社区 [weekArray addObject:@"Lunch"];
[weekArray addObject:[NSString stringWithFormat:@""]];
[weekArray addObject:[NSString stringWithFormat:@""]];
[weekArray addObject:@"After School"];
return weekArray;
I want to be able to call it and when called, replace weekArray with the array I choose. Possible?
Assuming I understand what you're asking, sure. Here's an example:
NSArray *arrayLikeThat() {
return [NSMutableArray arrayWithObjects: @"Before School",
[NSString stringWithFormat:@""],
[NSString stringWithFormat:@""],
@"Break",
[NSString stringWithFormat:@""],
[NSString stringWithFormat:@""],
@"Lunch",
[NSString stringWithFormat:@""],
[NSString stringWithFormat:@""],
@"After School",
nil];
}
You can assign the result to any variable you want.
精彩评论