[ad_1]
As I attempted to work on core information to see if it was the identical or wanted a brand new replace, I observed that if information core is modified, it would name a perform like 5-15 occasions in lower than 1-3 seconds which causes my tableview reload information to randomly reload. If my database and core information are the identical, I need to add one thing that does not require an replace. It is unusual, nonetheless, once I change one thing small, such because the title from take a look at to check 2, they inform me the core information is similar. This can replace if I alter one thing huge just like the title from take a look at to hiya world. After I change one thing small, why does my core information assume my database is similar?
EDIT: To create new or delete the merchandise, it would name replace however title won’t replace as a result of it assume core information and outdated database are identical.
Right here my code:
// MARK: Fetching the short reminder and replace the database
func fetchingDatabase() {
var getAllData: [TheDataName] = []
do {
let getRawDatabase = attempt contextDataCore.fetch(QuickReminder.fetchRequest())
for getData in getRawDatabase { getAllData.append(TheDataName(rawData: getData, title: getData.title, dateComplete: getData.isComplete)) }
var firstDataCheck: [QuickReminder] = []
var SecondDataCheck: [QuickReminder] = []
for firstRaw in getAllData { firstDataCheck.append(firstRaw.rawData) }
for secondRaw in TheDatabaseMemory.theQuickReminder { SecondDataCheck.append(secondRaw.rawData) }
if firstDataCheck != SecondDataCheck {
/// This can replace as a result of new information is not identical as outdated information
TheDatabaseMemory.theQuickReminder = getAllData
nc.put up(identify: NSNotification.Identify("Replace Database"), object: nil)
} else {
/// This can NOT have to replace as a result of new information is identical as outdated information
/// Nonetheless, there are some small data are modified, however why it does not have to replace?
/// I needed to kill app then open once more, lastly replace are contemporary
nc.put up(identify: NSNotification.Identify("No Replace Database"), object: nil)
}
} catch {
print("Error Learn Fast Reminder")
}
}
[ad_2]
