एक्सकोड 7 बीटा 6 और एनएसफ़ेटेड रीसेट कंट्रोलर ने मुझे आज सिरदर्द दिया। यदि मैं एक्सकोड 6 के साथ कोड (स्विफ्ट 2 फिक्स के साथ) संकलित करता हूं, तो प्रोग्राम डिवाइस और सिमुलेटर (आईओएस 7, आईओएस 8) पर काम करता है। हालांकि अगर मैं एक्सकोड 7 बीटा 6 के साथ संकलित करता हूं, तो जब भी मैं कोर डेटा अपडेट करता हूं, तो निम्न त्रुटि संदेशों के साथ डिवाइस (आईओएस 8.4) पर प्रोग्राम क्रैश हो जाता है।NSFetchedResultsController XCode 7 अंक
मैं करने के लिए
CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (2 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out). with userInfo (null)
नीचे कभी कभी यह .Update
अनुभाग के लिए
Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug
//NSFetchedResultsController delegates
func controllerWillChangeContent(controller: NSFetchedResultsController) {
self.tableView.beginUpdates()
}
func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {
switch type {
case .Insert:
self.tableView.insertSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade)
case .Delete:
self.tableView.deleteSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade)
default:
return
}
}
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
switch type {
case .Insert:
print("Insert New: \(newIndexPath) Old: \(indexPath)")
tableView.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: .Fade)
case .Delete:
print("Delete New: \(newIndexPath) Old: \(indexPath)")
tableView.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: .Fade)
case .Update:
print("Update New: \(newIndexPath) Old: \(indexPath)")
tableView.reloadRowsAtIndexPaths([indexPath!], withRowAnimation: .Fade)
//self.configureCell(tableView.cellForRowAtIndexPath(indexPath!)!, atIndexPath: indexPath!)
case .Move:
print("Move New: \(newIndexPath) Old: \(indexPath)")
tableView.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: .Fade)
tableView.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: .Fade)
}
}
func controllerDidChangeContent(controller: NSFetchedResultsController) {
self.tableView.endUpdates()
}
की तरह एक और त्रुटि के साथ दुर्घटनाओं समान कोई त्रुटि मिलती है मैं भी
self.configureCell(tableView.cellForRowAtIndexPath(indexPath!)!, atIndexPath: indexPath!)
कॉल करने की कोशिश
कॉन्फ़िगर सेल विधि:
func configureCell(cell: UITableViewCell, atIndexPath indexPath: NSIndexPath) {
let object = self.fetchedResultsController.objectAtIndexPath(indexPath) as! Person
//etc
}
क्रमबद्ध वर्णनकर्ता
let sortDescriptor = NSSortDescriptor(key: "date", ascending: false)
fetchRequest.sortDescriptors = [sortDescriptor]
कार्यक्रम हमेशा दुर्घटनाओं। इस मुद्दे को किसी भी तरह से रोकने का एकमात्र तरीका नील को अद्यतन करना, ऑब्जेक्ट अपडेट करना और स्वयं को वापस भेजना सेट करना है।
क्या यह एक बग है? यदि यह नहीं है, तो मैं इसे कैसे रोक सकता हूं? धन्यवाद
ही/समान मुद्दे के साथ कुछ बग रिपोर्ट
https://forums.developer.apple.com/thread/12184
https://forums.developer.apple.com/thread/4999
iOS 9 - "attempt to delete and reload the same index path"
मैं दोनों XCode6 और XCode7 संस्करणों भाग गया और didChangeObject
विधि यहाँ मुद्रित तुलना
XCode6 आईओएस 8,4
Update New: Optional(<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}) Old: Optional(<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0})
XCode 7b6 आईओएस 8,4
Update New: nil Old: Optional(<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0})
Insert New: Optional(<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}) Old: Optional(<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0})
2015-09-01 01:15:37.898 TestProg[3230:200562] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-3347.44.2/UITableView.m:1623
2015-09-01 01:15:37.900 TestProg[3230:200562] CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out). with userInfo (null)
मेरी वर्तमान प्रोजेक्ट में मैं 'कॉन्फ़िगरेशन' विधि का भी उपयोग करता हूं, मुझे लगता है कि मैंने इसे एक समान बग के कारण बदल दिया है। क्या आप शायद अपनी कॉन्फ़िगर सेल विधि दिखा सकते हैं? – Mundi
यह सबसे बॉयलरप्लेट कोड है। मेरे पास कई रिश्ते हैं। नीचे कुछ ऐसा है: func configCell (सेल: UITableViewCell, atIndexPath indexPath: NSIndexPath) { ऑब्जेक्ट = self.fetchedResultsController.objectAtIndexPath (indexPath) के रूप में दें! व्यक्ति // आदि } – Meanteacher
क्या आपके एफआरसी में एक प्रकार का वर्णनकर्ता है या एक प्रमुख मार्ग के माध्यम से रिश्ते का जिक्र करने वाला भविष्य है? यह कभी-कभी अप्रत्याशित परिणामों का कारण बन सकता है। – Mundi