我正在使用模式segue將數據從SignUpViewController傳遞到RAVerificationViewController。出於某種原因,我的姓名,密碼,電話和電子郵件值都是零,但會顯示宿舍和角色選擇(它們是從選取器中選擇的值)。我發現它們是從第一個視圖控制器正確傳遞的,但是它們不會在下一個視圖中顯示出來。幫幫我!PrepareForSegue不通過所有的數據?
- (void)prepareForSegue:(UIStoryboardPopoverSegue *)segue sender:(id)sender {
NSLog(@"prepareForSegue: %@", segue.identifier);
if ([segue.identifier isEqualToString:@"signUpToRAVerification"]) {
RAVerificationViewController *ravc = (RAVerificationViewController *)segue.destinationViewController;
NSInteger roleRow = [_rolePickerChoice selectedRowInComponent:0];
NSString *role = [self pickerView: _rolePickerChoice titleForRow:roleRow forComponent:1];
ravc.role = role;
NSString *email = _emailOneField.text;
ravc.name = _nameField.text;
ravc.password = _passwordTwoField.text;
ravc.email = email;
ravc.phoneNumber = _phoneNumberField.text;
NSInteger dormRow = [_dormPickerChoice selectedRowInComponent:0];
NSString *dorm = [self pickerView: _dormPickerChoice titleForRow:dormRow forComponent:1];
ravc.dormChoice= dorm;
}
}
我在其他VC與數據做什麼:
if([_raCodeField.text isEqualToString:code]) {
NSLog(@"The email is: %@", email);
//RA good to go, let's save him/her in our DB!
PFUser* user = [PFUser user];
user[@"role"] = _role;
user[@"Name"] = name;
user.password = password;
user.email = email;
user.username = email;
user[@"phone_number"] = phoneNumber;
user[@"dorm"] = _dormChoice;
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
對於整個SignUpViewController:https://gist.github.com/vinamratasingal/542dc10bf1674173d2de
對於整個raVerificationViewController:https://gist.github.com/vinamratasingal/758d3a11a3ddf6d7e3a3
缺少的下劃線是因爲類的頂部有「@synthesize」......它不能解決任何問題(我對它做了下劃線,然後爲每個破壞的屬性添加了@synthesize,並且沒有修復任何東西) – 2014-09-04 21:56:29
在大多數情況下,您不需要再使用@synthesize。這會自動照顧你。從您的兩個視圖控制器發佈更多代碼,以便我們可以看到如何完成所有設置。 – user3344977 2014-09-04 21:57:19
請參閱上面附加的文件鏈接到整個文件。我不確定什麼代碼是相關的,所以我發佈了兩個VC的鏈接。在這裏,他們又是:對於整個SignUpViewController:https://gist.github.com/vinamratasingal/542dc10bf1674173d2de 對於整個raVerificationViewController:https://gist.github.com/vinamratasingal/758d3a11a3ddf6d7e3a3 我還設置斷點和看到這四個變量(名稱,電子郵件等)的類變量爲零,但宿舍和角色的選擇正確設置。 – 2014-09-04 22:00:30