मैं चेतावनीसंग्रह दृश्य से आइटम को कैसे हटाएं?
में उपयोगकर्ता पसंद के आधार पर collectionview से आइटम को हटाने के लिए मैं कोड निम्नलिखित है की कोशिश
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let person = people[indexPath.item]
let questionController = UIAlertController(title: "What u wanna do?", message: nil, preferredStyle: .Alert)
questionController.addAction(UIAlertAction(title: "Rename person", style: .Default, handler: {
(action:UIAlertAction!) -> Void in
let ac = UIAlertController(title: "Rename person", message: nil, preferredStyle: .Alert)
ac.addTextFieldWithConfigurationHandler(nil)
ac.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
ac.addAction(UIAlertAction(title: "OK", style: .Default) { [unowned self, ac] _ in
let newName = ac.textFields![0] as! UITextField
person.name = newName.text
self.collectionView.reloadData() })
self.presentViewController(ac, animated: true, completion: nil)
}))
questionController.addAction(UIAlertAction(title: "Delete Person", style: .Default, handler: {
(action:UIAlertAction!) -> Void in
println("hello world")
self.collectionView.deleteItemsAtIndexPaths([indexPath.item])
self.collectionView.reloadData()
}))
presentViewController(questionController, animated: true, completion: nil)
}
हैलो दुनिया ठीक है और एप्लिकेशन क्रैश काम करता है जब मैं व्यक्ति को हटाना प्रेस
सांत्वना उत्पादन
हैhello world
2015-07-18 13:40:14.628 Project10[15888:1274436] -[__NSCFNumber section]: unrecognized selector sent to instance 0xb000000000000003
2015-07-18 13:40:14.636 Project10[15888:1274436] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber section]: unrecognized selector sent to instance 0xb000000000000003'
मैं क्या गलत कर रहा हूं?
मदद नहीं की असीमित अपवाद 'एनएसआईएन इंटरनेशनल इन्कॉन्सिस्टेंसी अपवाद' के कारण ऐप को समाप्त करना, कारण: 'अमान्य अद्यतन: खंड 0 में आइटम की अमान्य संख्या अद्यतन (1) के बाद मौजूदा खंड में निहित वस्तुओं की संख्या बराबर होनी चाहिए अद्यतन (1) से पहले उस खंड में निहित वस्तुओं की संख्या, उस अनुभाग से सम्मिलित या हटाए गए आइटमों की संख्या या घटाएं (0 डाला गया, 1 हटाया गया) और उस अनुभाग के अंदर या बाहर स्थानांतरित वस्तुओं की संख्या को घटाएं या घटाएं (0 में स्थानांतरित हो गया, 0 बाहर चले गए)। ' –
अपना डेटा स्रोत अपडेट करना न भूलें - व्यक्ति को 'लोगों' सरणी से हटा दिया जाना है। – Glorfindel
क्षमा करें, मैं तेजी से नया हूं - डेटा स्रोत कैसे अपडेट करें? –