我在我的主應用程序中嵌入了一個簡單的待辦事項列表, 我已經在一個單獨的項目中建立了它,然後我將其添加到我的主項目中,一切都很好,但是,當我編寫待辦事項並單擊保存按鈕時,程序崩潰了!問題是什麼?如果程序崩潰,點擊保存按鈕時會出現什麼問題?
我的代碼:
self.navigationItem.rightBarButtonItem =
[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
target:self
action:@selector(save_Clicked:)]
autorelease];
那麼save_Clicked實現:
- (void) save_Clicked:(id)sender {
HomeAppDelegate *appDelegate =
(HomeAppDelegate *)[[UIApplication sharedApplication] delegate];
//Create a todo Object.
todo *todoObj = [[todo alloc] initWithPrimaryKey:0];
todoObj.todotitle = txttodotitle.text;
todoObj.tododes = txttododes.text;
/*
NSString *temp = [[NSString alloc] initWithString:txttododes.text];
todoObj.tododes = temp;
[temp release];
*/
todoObj.isDirty = NO;
todoObj.isDetailViewHydrated = YES;
//Add the object
[appDelegate addtodo:todoObj];
//Dismiss the controller.
[self.navigationController dismissModalViewControllerAnimated:YES];
}
和輸出誤差按摩控制檯是:
2010-06-03 17:12 :45.720首頁[29728:207]沒有錯誤 2010-06-03 17:12:45.726主頁[29728:207]警告:由於委託我使用舊版單元佈局mplementation的tableView:accessoryTypeForRowWithIndexPath:in。請移除此方法的實施並將單元格屬性accessoryType和/或editingAccessoryType設置爲移至新單元格佈局行爲。此方法將不再在將來的版本中調用。 2010-06-03 17:12:59.447首頁[29728:207] *斷言在 - [todo addtodo]中失敗,/ Users/HOME/Desktop/withretriveAnn/Home copy 5-ToDO/Classes/todo.m:90 2010-06-03 17:12:59.448首頁[29728:207] *由於未捕獲異常'NSInternalInconsistencyException',原因:'創建添加語句時出錯。 「沒有這樣的表:待辦事項」
- 我肯定用iPhone數據庫來保存待辦列表。
可能有助於發佈代碼... – 2010-06-03 14:12:57
當您的應用程序崩潰時,請提供您的代碼,或者至少提供Xcode控制檯中輸出的錯誤消息。 – mcandre 2010-06-03 14:14:43
...它可以在任何地方。沒有看到代碼,這個問題是不可能回答的。沒有看到崩潰消息,這個問題是不可能回答的。請更新您的問題 – coneybeare 2010-06-03 14:15:02