我正在创建一个iOS应用,在第一个屏幕上显示一个名为itemsList的数组中的项目列表
@property (nonatomic, retain) NSMutableArray *itemsList;
点击+按钮添加项目时,会出现一系列名为addNewItem的预设项目
@property (nonatomic, retain) NSMutableArray *addNewItem;
当点击该单元格时,如何将tapped单元格中的数据传输到itemsList数组,将其从addNewItem数组中完全删除,因为它们位于两个不同的实现文件中?
答案 0 :(得分:0)
首先,请使用ARC,因此请声明您的属性:
@property (nonatomic, strong) NSMutableArray *itemsList;
@property (nonatomic, strong) NSMutableArray *addNewItem;
然后:
[self.itemsList addItemsFromArray:self.addNewItem];
[self.addNewItem removeAllObjects];
应该这样做。
答案 1 :(得分:0)
// FirstViewController
// .h File
SecondViewController *sec;
NSMutableArray *arrayWhichYouPass;
// .m File
arrayWhichYouPass = [[NSMutableArray alloc] init];
[arrayWhichYouPass addObject:@"Jayesh"];
[arrayWhichYouPass addObject:@"Jatin"];
[arrayWhichYouPass addObject:@"Jay"];
[arrayWhichYouPass addObject:@"Vishal"];
[arrayWhichYouPass addObject:@"Amit"];
- (IBAction) buttonClicked : (id) sender
{
sec = [[SecondViewController alloc] initWithNib:@"SecondViewController"]...];
sec.arrGetData = arrayWhichYouPass;
}
// SecondViewController
// .h File
// Give Property to array which get the array data from FirstViewController
@property (nonautomic, retain) NSMutableArray *arrGetData;
// .m File
@sysnthesize arrGetData;
NSLog(@"%@",arrGetData);