2015-09-10 1 views
3

enter image description here Je reçois cette erreur lors du passage à un contrôleur de vue sur mon TabBarController:NSCFNumber rangeOfCharacterFromSet Parse error

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0xb000000000000043' 
*** First throw call stack: 
(0x182a2422c 0x1946f00e4 0x182a2b2f4 0x182a280a8 0x18292a96c 0x187bf48c4 0x1874ddf68 0x10000ace8 0x10000a904 0x1874b7da8 0x18756f68c 0x180e30fb8 0x1874b7da8 0x1874b8314 0x1877e2d8c 0x1875240c0 0x187524028 0x1874944fc 0x1829dbff0 0x1829d8f7c 0x1829d935c 0x182904f74 0x18c35f6fc 0x187506d94 0x10000cb10 0x194d9aa08) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 

J'ai le sentiment qu'il doit faire face à mon yosTextField, qui est un nombre (Yos signifie Years of Service). les champs de texte sont implantés à l'intérieur d'une vue déroulante de sorte que les champs de texte défilent au-dessus du clavier. Code:

#pragma mark - Backend actions 

//------------------------------------------------------------------------------------------------------------------------------------------------- 
- (void)loadUser 
//------------------------------------------------------------------------------------------------------------------------------------------------- 
{ 
    PFUser *user = [PFUser currentUser]; 

    [imageUser setFile:user[PF_USER_PICTURE]]; 
    [imageUser loadInBackground]; 

    backgroundTextView.text = user[@"background"]; 
    companyTextField.text = user[@"company"]; 
    yosTextField.text = user[@"yos"]; 


    fieldName.text = user[PF_USER_FULLNAME]; 
    emailAddressTxtField.text = user[PF_USER_EMAIL]; 
} 

//------------------------------------------------------------------------------------------------------------------------------------------------- 
- (void)saveUser 
//------------------------------------------------------------------------------------------------------------------------------------------------- 
{ 
    NSLog(@"save touched"); 
    NSString *fullname = fieldName.text; 
    NSString *email = emailAddressTxtField.text; 
    NSString *background = backgroundTextView.text; 
    NSNumber *YOS = [NSNumber numberWithInt:[[yosTextField text] intValue]]; 
    NSString *company = companyTextField.text; 
    if (([fullname length] != 0) || ([email length] != 0) || ([background length] != 0) || ([company length] != 0) || (YOS != 0)) 
    { 
     PFUser *user = [PFUser currentUser]; 
     user[PF_USER_FULLNAME] = fullname; 
     user[PF_USER_FULLNAME_LOWER] = [fullname lowercaseString]; 
     user[PF_USER_EMAIL] = email; 
     user[@"background"] = background; 
     user[@"company"] = company; 
     user[@"yos"] = YOS; 

     [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) 
     { 
      if (error == nil) 
      { 
       [ProgressHUD showSuccess:@"Saved."]; 
      } 
      else [ProgressHUD showError:@"Network error."]; 
     }]; 
    } 
    else [ProgressHUD showError:@"Name field must be set."]; 
} 

Répondre

11

L'erreur indique que vous utilisez une méthode NSString sur un NSNumber. Plese, vérifiez si vos données sont des chaînes.

Espérons que ça aide.

+0

merci beaucoup. – hilaj

+0

Merci beaucoup ... ça a marché pour moi :) –