所以我目前正在尝试构建一个具有社交方面的iOS应用程序。因此,用户将拥有自己的个人资料,而不是。我试图从注册页面直接指向构建配置文件页面。我暂时使用parse.com作为我的后端。模拟器运行良好,直到我填写文本字段并按下注册按钮然后它崩溃说“由于未捕获的异常终止应用程序'NSInvalidArgumentException',原因:'无效的类名。类名不能以下划线开头。”
任何想法都有错吗?
- (BOOL) shouldPerformSegueWithIdentifier:(NSString *)showBuildProfile sender:(id)sender {
NSString *firstname = [self.firstNameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *lastname = [self.lastNameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *username = [self.userField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *email = [self.emailField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([firstname length] == 0 || [lastname length] == 0 || [username length] == 0 || [password length] == 0 || [email length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops" message:@"Make sure you fill in all of the information." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
return NO;
} else {
PFUser *newUser = [PFUser user];
newUser.username = username;
newUser.password = password;
newUser.email = email;
newUser[@"first name"] = self.firstNameField;
newUser[@"last name"] = self.lastNameField;
[newUser signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error){
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:[error.userInfo objectForKey:@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
} else {
//Sign up the user.
}
}];
return YES; }
}
答案 0 :(得分:0)
您需要使用textFields的text属性
newUser[@"firstName"] = self.firstNameField.text;
newUser[@"lastName"] = self.lastNameField.text;
// also notice I removed the spaces, spaces make me nervous.