每次运行此方法时,都会创建并初始化我的数组。我怎样才能保持数组填充,直到
- 移动到另一个视图或
选择另一个按钮(我们称之为“重置”)。
- (IBAction)addItemToOrder:(id)sender { NSMutableArray *arrayOrderItems = [[NSMutableArray alloc]init]; NSMutableString *stringOrderItem = [[NSMutableString alloc]initWithString:@"Item: "]; [stringOrderItem appendString:self.labelProductCode.text]; [stringOrderItem appendString:@" | Qty: "]; [stringOrderItem appendString:self.textfieldQuantity.text]; NSObject *myObj = [[NSObject alloc]init]; myObj = stringOrderItem; [arrayOrderItems addObject:myObj]; self.textviewOrderTotal.text = stringOrderItem; NSLog(@"arrayOrderItems: #records: %d", arrayOrderItems.count); NSLog(@"%@", arrayOrderItems); }