我的iOS應用程序需要經過幾次tableviews才能將數據添加到基於字典的配置文件類。當用戶完成配置文件時,他們可以跳過下一次登錄,以跳過配置文件構建(以及這些表格視圖),但是如果他們選擇,他們可以重建他們的配置文件。我使用segues逐步向前傳遞配置文件類。在重建時,應用程序跳回到開頭。問題:在重建時,配置文件在傳遞到第一個tableview(國籍)時消失。 這裏的一個比特的代碼:當用戶更新內容時,使用segue的傳遞字典類失敗
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSMutableArray *sendArray = [[NSMutableArray alloc] initWithObjects:user0, nil];
NSLog(@"send array = %@", sendArray);
if(buildPf) { // to Nationality VC
if ([[segue identifier] isEqualToString:@"getNationality"]) {
Nationality_TableVC *vc = [segue destinationViewController];
vc.profiles0 = sendArray;
}
} else { // to Profile VC
if([[segue identifier] isEqualToString:@"directToProfile"]) {
YourProfile_VC *vc = [segue destinationViewController];
vc.profiles10 = sendArray;
[vc setPushID:[user0.userID integerValue]];
[vc setPushedPf:profileSum];
}
}
}
在Nationality_VC中,.H:
@property(強,非原子)的NSMutableArray * profiles0;
在.M:
@implementation Nationality_TableVC {
NSUInteger selectedIndex;
NSUInteger selectedRow;
Profile *user0;
}
- (void)viewDidLoad {
[super viewDidLoad];
user0 = [[Profile alloc] init];
user0 = [self.profiles0 objectAtIndex:0];
NSLog(@"(Nationality) user0 is %@", user0);
selectedRow = -1;
[self makeTableIndex];
}
通過調試,我可以看到這個類跳回後正確填充。 sendArray總是正確的。通過在初始構建過程中運行的相同過程,配置文件消失。爲什麼? 該應用程序崩潰。在國籍tableview中,我有一個NSLog。在最初的構建,該消息是:
(Nationality) user0 is <Profile: 0x7152330>
在重建期間,該消息是:
(Nationality) user0 is (null)
然後試圖將國籍選擇添加到(空)配置文件,當然,導致崩潰。 如果用戶選擇重建,然後改變主意,他們可以再次直接跳到完成的配置文件。如果他們這樣做,segue會正確地通過配置文件類。沒問題。 什麼可能導致失蹤?
除了作爲一個弱編碼器之外,我在stackoverflow問題上也不是很棒。我怎樣才能改善我的問題? –
你有一個用於'sendArray'的NSLog,但是你不會說它顯示了什麼。 –
它顯示配置文件類的內容並始終正確。 –