【发布时间】:2016-11-08 14:40:00
【问题描述】:
我有一个返回一些字符串的函数
func getURLsToSend () {
//create a fetch request, telling it about the entity
let fetchRequest: NSFetchRequest<URLsToSend> = URLsToSend.fetchRequest()
do {
//Get results
let searchResults = try getContext().fetch(fetchRequest)
//You need to convert to NSManagedObject to use 'for' loops
for urls in searchResults as [NSManagedObject] {
//get the Key Value pairs (although there may be a better way to do that...
print("\(urls.value(forKey: "url"))")
//Process URL
//Delete from Core Data
}
} catch {
print("Error with request: \(error)")
}
}
正如您在找到每个字符串(它是一个 url)后在 cmets 中看到的那样,我需要能够处理它然后删除它。
我可以处理我所拥有的一切,这很好我只是不知道如何从核心数据中删除对象,有人可以帮我解释一下吗?
【问题讨论】:
标签: swift xcode core-data swift3