目前我正在一行中填充一个数组,例如
self.monthMonths = [[NSArray alloc] initWithObjects:@"January", @"February", @"March", @"April", @"May", @"June",@"July",@"August",@"September",@"October",@"November",@"December", nil];
当我想从数据库中提取数据时,一次添加这些元素的语法是什么。我以一年中的月份为例。
while([results next]) {
NSString *months = [results stringForColumn:@"month"];
self.month = [[NSArray alloc] initWithObjects:@"month",nil];
//[NSArray
NSLog(@"Month: %@",month);
}
最佳答案
创建一个 NSMutableArray 并使用 addObject
将对象一一添加到其中
关于xcode - 一次构建一个元素的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11348768/