테이블 뷰에서 저장된 데이터를 업데이트 할 수 없지만 저장된 데이터를 대상 뷰 컨트롤러의 텍스트 필드로 전달할 수 있지만 업데이트 할 수없는 핵심 데이터 문제가 있습니다. 이전 뷰 컨트롤러로 전달합니다. 텍스트 필드에서 편집 할 수는 있지만 데이터가 이전에 저장되었던 이전 테이블보기 컨트롤러의 내용을 업데이트 할 수 없습니다.코어 데이터의 저장된 데이터를 업데이트 할 수 없습니다.
func Plus(sender: AnyObject) {
if store == nil
{
//get the description of the entity
let storeDescription = NSEntityDescription.entityForName("Store",inManagedObjectContext: appdelegate.managedObjectContext)
//we create managed object to be inserted to core data
let store = EventsandnotesStore(entity : storeDescription!,insertIntoManagedObjectContext:appdelegate.managedObjectContext)
store.sName = name.text
store.sDescription = desc.text
let img = UIImage(named: "image.jpg")
let imgData = UIImageJPEGRepresentation(img!,1)
store.sImage = imgData
do {
try appdelegate.managedObjectContext.save()
self.navigationController?.popViewControllerAnimated(true)
} catch let error as NSError {
print("Could not save \(error), \(error.userInfo)")
}
}
표시중인 코어 데이터 저장은보기 컨트롤러에서 데이터를 표시하는 코드가 아닙니다. 해당 코드를 표시해야합니다. – Daniel
편집 된 텍스트 필드 내용을 핵심 데이터로 업데이트하는 방법을 모릅니다. 아래에 나는 –
에게 다음 뷰 컨트롤러로 데이터를 전달하는 코드를 주었다. 재정의 func prepareForSegue (segue : UIStoryboardSegue, 보낸 사람 : AnyObject?) { if segue.identifier == "show" { v를 = segue.destinationViewController로 설정하십시오! ViewController let indexpath = self.tableView.indexPathForSelectedRow! let row = indexpath.row v.store = stores [행] } 핵심 데이터의 내용을 업데이트하는 코드를 알려주십시오. 나는 신속하고 응용 프로그램 개발에 새로운입니다. –