PDA

View Full Version : How to solve "[UITextField isEqualToString:]"




mikezang
Aug 10, 2010, 11:29 PM
I use code as below to save data, but I got error like this, what can I do?
[Session started at 2010-08-11 13:14:01 +0900.]
2010-08-11 13:14:11.432 StockManager[285:207] *** -[UITextField isEqualToString:]: unrecognized selector sent to instance 0x4d36640
2010-08-11 13:14:11.434 StockManager[285:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UITextField isEqualToString:]: unrecognized selector sent to instance 0x4d36640'


@interface TradeDetailController : UITableViewController <UITextFieldDelegate> {
Trade *trade;
NSArray *fieldLabels;
NSMutableDictionary *tempValues;
UITextField *textFieldBeginEdited;
}

@property (nonatomic, retain) Trade *trade;
@property (nonatomic, retain) NSArray *fieldLabels;
@property (nonatomic, retain) NSMutableDictionary *tempValues;
@property (nonatomic, retain) UITextField *textFieldBeginEdited;


-(IBAction) save:(id)sender {
if (textFieldBeginEdited != nil) {
NSNumber *tagAsNum = [[NSNumber alloc] initWithInt:textFieldBeginEdited.tag];
[tempValues setObject:textFieldBeginEdited.text forKey:tagAsNum];
[tagAsNum release];
}

for (NSNumber *key in [tempValues allKeys]) {
switch ([key intValue]) {
case kStartDateRowIndex:
trade.startDate = [tempValues objectForKey:key];
break;

case kEndDateRowIndex:
trade.endDate = [tempValues objectForKey:key];
break;

case kTradeTypeRowIndex:
trade.tradeType = [tempValues objectForKey:key];
break;

case kCodeRowIndex:
trade.code = [tempValues objectForKey:key];
break;

case kAmountRowIndex:
trade.amount = [tempValues objectForKey:key];
break;

case kStartPriceRowIndex:
trade.startPrice = [tempValues objectForKey:key];
break;

case kEndPriceRowIndex:
trade.endPrice = [tempValues objectForKey:key];
break;

case kFeeRowIndex:
trade.fee = [tempValues objectForKey:key];
break;

case kTaxRowIndex:
trade.tax = [tempValues objectForKey:key];
break;

case kInterestRowIndex:
trade.interest = [tempValues objectForKey:key];
break;

default:
break;
}
}

[self.navigationController popViewControllerAnimated:YES];

NSArray *allControllers = self.navigationController.viewControllers;
TradeViewController *parent = [allControllers lastObject];
[parent.rowDetail reloadData];
}



pflau
Aug 11, 2010, 12:26 AM
A text field is a field, it is not a string.

Find the text property and try again.

mikezang
Aug 11, 2010, 12:27 AM
Sorry for this thread, I got answer because I put code in textFieldDidEndEditing into textFieldDidBeginEditing.