I have custom UICollectionVIewCell with UILabel and UITextfield as it's property. They both IBOutlet to and connected in Storyboard. This cell get reused in a UICollection view. It get created depending on UILabel count array. So if array has three strings, this cell get created three times. User supposed to enter number in UITextfiled for relevant label. I want to save this number along with label in a dictionary. My problem is I can't get text from UITextfield. Don't know how to do that. I have tried creating instance of UICollectionViewCell and it's textfield property. It's always nil. So app crashes. Please help
OtherPaymentListViewController.h
@interface OtherPaymentListViewController : UIViewController<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@end
//next
@interface OtherPayDeductionCell : UICollectionViewCell
//this is for payment
@property (nonatomic, strong) IBOutlet UILabel *otherPayDeductionTitleLabel;
@property (nonatomic, strong) IBOutlet UITextField *otherPayDeductionAmountTextField;
@end
//data model
@interface OtherPayDeductionsData : NSObject
@property (nonatomic, strong) NSMutableDictionary *otherPaymentsDect;
/*
this dictionary consists of a title from UITextField out side UICollectionViewCell, an array storing UISwitches selected values also out side UICollectionViewCell, and number string which comes form UITextField in UICollectionViewCell.
*/
@end
//thats where I tried to get textField text
- (IBAction)unwindToViewController:(UIStoryboardSegue *)segue
{
//called by cancel and save buttons in otherPaymentViewController
NSString *otherPaymentAmountKey = @"other payment key";
NSString *otherPaymentAmount = @"other payment amount";
OtherPaymentListViewController *source = [segue sourceViewController];
//add amount from textbox
OtherPayDeductionCell *otherPayDeductionCell = [[OtherPayDeductionCell alloc]init];
otherPaymentAmount = otherPayDeductionCell.otherPayDeductionAmountTextField.text;
//otherPaymentAmount always nil. Although textfield has some numbers in it.
[source.otherpaymentDict setObject:otherPaymentAmount forKey:otherPaymentAmountKey];
NSLog(@"Dictionary %@", source.otherpaymentDict);
}