Hi this is my first question
look my code. I dont understand why my array becomes null after changing view FirstView: I try tu use a delegate but it's not working. my delegate is never call.
h:
@interface CaisseViewController : UIViewController <testDelegate>
@property (nonatomic, retain) NSMutableArray *testArray;
-(void)autrePaiementChoisie:(AutrePaiementCaisseTableViewController*)controller selectPaiement:(NSString *)paiement;
@end
m:
@synthesize testArray;
- (void)viewDidLoad
{
testArray = [[NSMutableArray alloc]initWithObjects:@"TEST 1",@"TEST 2", nil];
}
- (IBAction)autre:(id)sender {
NSLog(@"testArray %@",testArray); // OK !
[self performSegueWithIdentifier:@"autre" sender:self];
}
-(void)autrePaiementChoisie:(AutrePaiementCaisseTableViewController*)controller selectPaiement:(NSString *)paiement {
[controller dismissViewControllerAnimated:YES completion:nil];
NSLog(@"TEST ARRAY %@",testArray); // Is NULL
}
//function of my delegate
-(void)sendString:(NSString *)aString {
NSLog(@"string %@",aString); //dont work ! never called
}
SecondView: declare the delegate h:
@protocol testDelegate <NSObject>
-(void)sendString:(NSString*)aString;
@end
@property (nonatomic,assign) id<testDelegate>delegate;
m:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *paiement = [self.paiementArray objectAtIndex:indexPath.row];
[self.delegate sendString:[paiement valueForKey:@"nom"]]; //talk with my delegate
// CaisseViewController *caisseView = [[CaisseViewController alloc]init];
//[caisseView autrePaiementChoisie:self selectPaiement:[paiement valueForKey:@"nom"]];
}