How to solve "[UITextField isEqualToString:]"

Discussion in 'iOS Programming' started by mikezang, Aug 10, 2010.

  1. macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #1
    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'


    Code:
    @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;
    
    Code:
    -(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];
    }
    
     

    Attached Files:

  2. macrumors 6502

    Joined:
    Sep 17, 2007
    #2
    A text field is a field, it is not a string.

    Find the text property and try again.
     
  3. thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #3
    Sorry for this thread, I got answer because I put code in textFieldDidEndEditing into textFieldDidBeginEditing.
     

Share This Page