I've created an application in xcode that gets the location of a place from a user longclick on a map and inserte into a database. i keep getting this error
Travel Map Book[17935:3752754] *** Terminating app due to uncaught exception
'NSUnknownKeyException', reason: '[<Locations 0x60800009f630>
valueForUndefinedKey:]: the entity Locations is not key value coding-compliant
for the key "longtitude".'
*** First throw call stack:
(
0 CoreFoundation 0x00000001065d2b0b
__exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000102870141 objc_exception_throw + 48
2 CoreFoundation 0x00000001065d2a59 -[NSException raise] + 9
3 CoreData 0x0000000102de121b -[NSManagedObject valueForUndefinedKey:] + 299
4 Travel Map Book 0x00000001021e04d7 _TFC15Travel_Map_Book19FirstViewController9fetchDatafT_T_ + 7159
5 Travel Map Book 0x00000001021de18a _TFC15Travel_Map_Book19FirstViewController11viewDidLoadfT_T_ + 490
6 Travel Map Book 0x00000001021de202 _TToFC15Travel_Map_Book19FirstViewController11viewDidLoadfT_T_ + 34
7 UIKit 0x00000001036ab01a -[UIViewController loadViewIfRequired] + 1235
8 UIKit 0x00000001036e9e6c -[UINavigationController _layoutViewController:] + 56
9 UIKit 0x00000001036ea74a -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 466
10 UIKit 0x00000001036ea8bb -[UINavigationController _startTransition:fromViewController:toViewController:] + 127
11 UIKit 0x00000001036eba03 -[UINavigationController _startDeferredTransitionIfNeeded:] + 843
12 UIKit 0x00000001036ecb41 -[UINavigationController __viewWillLayoutSubviews] + 58
13 UIKit 0x00000001038de60c -[UILayoutContainerView layoutSubviews] + 231
14 UIKit 0x00000001035cb55b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
15 QuartzCore 0x000000010b7bd904 -[CALayer layoutSublayers] + 146
16 QuartzCore 0x000000010b7b1526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
17 QuartzCore 0x000000010b7b13a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
18 QuartzCore 0x000000010b740e92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
19 QuartzCore 0x000000010b76d130 _ZN2CA11Transaction6commitEv + 468
20 QuartzCore 0x000000010b76db37 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 115
21 CoreFoundation 0x0000000106578717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
22 CoreFoundation 0x0000000106578687 __CFRunLoopDoObservers + 391
23 CoreFoundation 0x000000010655d038 CFRunLoopRunSpecific + 440
24 UIKit 0x000000010350208f -[UIApplication _run] + 468
25 UIKit 0x0000000103508134 UIApplicationMain + 159
26 Travel Map Book 0x00000001021dd177 main + 55
27 libdyld.dylib 0x0000000106f9f65d start + 1
28 ??? 0x0000000000000001 0x0 + 1
) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
I have tried cross-checking every spelling and data-type, still no luck with it. this is my fetchdata function
func fetchData(){
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let context = appDelegate.persistentContainer.viewContext
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "Locations")
request.returnsObjectsAsFaults = false
do {
let results = try context.fetch(request)
if results.count > 0{
self.titleArray.removeAll(keepingCapacity: false)
self.subtitleArray.removeAll(keepingCapacity: false)
self.longtitudeArray.removeAll(keepingCapacity: false)
self.latitudeArray.removeAll(keepingCapacity: false)
for result in results as! [NSManagedObject]{
if let title = result.value(forKey: "title") as? String{
self.titleArray.append(title)
}
if let subtitle = result.value(forKey: "subtitle") as? String{
self.subtitleArray.append(subtitle)
}
if let latitude = result.value(forKey: "latitude") as? Double{
self.latitudeArray.append(latitude)
}
if let longtitude = result.value(forKey: "longitude") as? Double{
self.longtitudeArray.append(longtitude)
}
self.tableView.reloadData()
}
}
} catch {
print("error")
}
}