我想在我的 NSMutable 中添加一个 NSArray(在 appdelegate 中初始化)
这是我的代码,每次按下按钮(男性,女性,情侣)时都会调用该方法,因此必须将 NSArray 添加到 MutableArray 但我不知道我尝试了一些东西但没有用。:
- (void) sexChoosen:(NSString *) sexe
{
NSError *err;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Boxes" inManagedObjectContext:context];
[request setEntity:entity];
NSArray *arrayForPredicate = [context executeFetchRequest:request error:&err];
NSPredicate *sex;
sex = [NSPredicate predicateWithFormat:@"sexe = %@", sexe];
NSArray *BoxWithSex = [arrayForPredicate filteredArrayUsingPredicate:sex];
//NSMutableArray* tmp = [self createMutableArray:BoxWithSex];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"FIRST %@", appDelegate.myArray);
// HERE IS THE CODE TO ADD THE ARRAY TO MY NSMUTABLE ARRAY = AppDelegate *appDelegate
NSLog(@"SECOND %@", appDelegate.myArray);
}