0
嘿,所有人,在這幾天一直在撓頭,但仍然不知道該怎麼做。製作一個UIButton將數據添加到核心數據模型
我有一個UIButton,通過點擊它我想它將數據添加到我的核心數據模型。目前,我正在使用我的Core Data UITableViewController中的navigationItem.rightBarButtonItem = addButton;
來添加數據,但我喜歡將UIViewController連接到核心數據模型,並讓UIButton向它添加數據。
例如,單擊此UIbutton時,它將切換到另一個視圖,同時也將數據添加到核心數據模型。
-(IBAction)changeviewandadddata {
SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:screen animated:YES];
[screen release];
}
任何幫助或如何做到這一點的建議,將不勝感激。
嗨,謝謝你的申請,我將如何實現這個到uibutton函數? – 2011-04-16 19:33:37
您可以將該代碼放入方法中。您需要替換的唯一東西就是對managedObjectContext的引用。 – 2011-04-16 21:34:52