I have a problem with Place Picker in my simulator. it is crashing with
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c15dd4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010bbbf21e objc_exception_throw + 48
2 CoreFoundation 0x000000010c07415f -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 351
3 CoreFoundation 0x000000010c073fcb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
4 myApp 0x0000000106f64c58 -[GMSPlatformKeyInsertingPlacesServerClient setPlacesService:] + 376
5 myApp 0x0000000106f64ac6 -[GMSPlatformKeyInsertingPlacesServerClient placesService] + 104
6 myApp 0x0000000106f64163 -[GMSPlatformKeyInsertingPlacesServerClient executeQuery:completionHandler:] + 88
7 myApp 0x0000000106f639f3 -[GMSPlacesServerClient accountPlacePickerSessionWithRequestSource:callback:] + 343
8 myApp 0x0000000106f88d60 -[GMSPlacesClient accountPlacePickerSessionWithCallback:] + 147
9 myApp 0x0000000106f58564 -[GMSPlacePicker pickPlaceWithResultCallback:didDisappearCallback:] + 887
10 myApp 0x0000000106b12273 _TFC6Medico11NewAdressVC13chooseAddressfT_T_ + 259
11 myApp 0x0000000106b11449 _TFC6Medico11NewAdressVC11viewDidLoadfT_T_ + 985
12 myApp 0x0000000106b12152 _TToFC6Medico11NewAdressVC11viewDidLoadfT_T_ + 34
13 UIKit 0x0000000109c11a3d -[UIViewController loadViewIfRequired] + 1258
14 UIKit 0x0000000109c18062 -[UIViewController __viewWillAppear:] + 118
15 UIKit 0x0000000109c431d3 -[UINavigationController _startCustomTransition:] + 1290
16 UIKit 0x0000000109c53e48 -[UINavigationController _startDeferredTransitionIfNeeded:] + 697
17 UIKit 0x0000000109c54fdb -[UINavigationController __viewWillLayoutSubviews] + 58
18 UIKit 0x0000000109e4bdd7 -[UILayoutContainerView layoutSubviews] + 223
19 UIKit 0x0000000109b34ab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
20 QuartzCore 0x0000000109686bf8 -[CALayer layoutSublayers] + 146
21 QuartzCore 0x000000010967a440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
22 QuartzCore 0x000000010967a2be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
23 QuartzCore 0x0000000109608318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
24 QuartzCore 0x00000001096353ff _ZN2CA11Transaction6commitEv + 475
25 QuartzCore 0x0000000109635d6f _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
26 CoreFoundation 0x000000010c102267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
27 CoreFoundation 0x000000010c1021d7 __CFRunLoopDoObservers + 391
28 CoreFoundation 0x000000010c0e6f8e __CFRunLoopRun + 1198
29 CoreFoundation 0x000000010c0e6884 CFRunLoopRunSpecific + 420
30 GraphicsServices 0x000000010ec0ea6f GSEventRunModal + 161
31 UIKit 0x0000000109a6fc68 UIApplicationMain + 159
32 myApp 0x0000000106ba8c2f main + 111
33 libdyld.dylib 0x000000010d1a468d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I don't know why it is crashing, because it start crashing yesterday. But on device all ok
Here is my code, but even if I put this callback empty it still crashing. I don't know what to do
let config = GMSPlacePickerConfig(viewport: nil)
let placePicker = GMSPlacePicker(config: config)
placePicker.pickPlace(callback: { (place: GMSPlace?, error: Error?) -> Void in
if let error = error {
print("Pick Place error: \(error.localizedDescription)")
return
}
guard let place = place else {
print("No place selected")
return
}
let camera = GMSCameraPosition.camera(withLatitude: place.coordinate.latitude, longitude: place.coordinate.longitude, zoom: 18)
self.mapView.camera = camera
self.marker.position = place.coordinate
self.marker.map = self.mapView
self.marker.appearAnimation = .pop
print("#Place address \(place.formattedAddress)")
if let addr = place.formattedAddress {
self.addressString = addr
}
self.updateAddressCell(place)
self.lastSelectedPlace = place
self.saveChangesButton.isHidden = false
})
Related
I am trying to save the JSON response in the realm using Alamofire and ObjectMapper. And I am getting this error:
* Terminating app due to uncaught exception 'RLMException', reason: 'Index 0 is out of bounds (must be less than 0).'
* First throw call stack:
(
0 CoreFoundation 0x00000001113e18db exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000110984ac5 objc_exception_throw + 48
2 Realm 0x000000010e30efee _Z20RLMThrowResultsErrorP8NSString + 670
3 Realm 0x000000010e310206 _ZL25translateRLMResultsErrorsIZ28-[RLMResults objectAtIndex:]E3$_6EDaOT_P8NSString + 118
4 Realm 0x000000010e310136 -[RLMResults objectAtIndex:] + 102
5 RealmSwift 0x000000010fa37436 $s10RealmSwift7ResultsCyxSicig + 262
6 App Name 0x000000010c0e9155 $s24Mahalaxmi_Life_Insurance12CalculatorVCC14collectionView_22numberOfItemsInSectionSiSo012UICollectionG0C_SitF + 197
7 App Name 0x000000010c0e934c $s24Mahalaxmi_Life_Insurance12CalculatorVCC14collectionView_22numberOfItemsInSectionSiSo012UICollectionG0C_SitFTo + 76
8 UIKitCore 0x00000001155dd2c3 -[UICollectionViewData _updateItemCounts] + 409
9 UIKitCore 0x00000001155dfb4f -[UICollectionViewData numberOfSections] + 22
10 UIKitCore 0x00000001155eafbe -[UICollectionViewFlowLayout _getSizingInfosWithExistingSizingDictionary:] + 511
11 UIKitCore 0x00000001155ed228 -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 231
12 UIKitCore 0x00000001155e5dc1 -[UICollectionViewFlowLayout prepareLayout] + 246
13 UIKitCore 0x00000001155dd5a8 -[UICollectionViewData _prepareToLoadData] + 212
14 UIKitCore 0x00000001155ddfb4 -[UICollectionViewData validateLayoutInRect:] + 53
15 UIKitCore 0x00000001155acec6 -[UICollectionView layoutSubviews] + 261
16 UIKitCore 0x000000011620ae69 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1417
17 QuartzCore 0x000000010de75d22 -[CALayer layoutSublayers] + 173
18 QuartzCore 0x000000010de7a9fc _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 396
19 QuartzCore 0x000000010de86d58 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 72
20 QuartzCore 0x000000010ddf624a _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 328
21 QuartzCore 0x000000010de2d606 _ZN2CA11Transaction6commitEv + 610
22 UIKitCore 0x0000000115d5399c _afterCACommitHandler + 245
23 CoreFoundation 0x00000001113482c7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
24 CoreFoundation 0x000000011134278e __CFRunLoopDoObservers + 430
25 CoreFoundation 0x0000000111342e01 __CFRunLoopRun + 1505
26 CoreFoundation 0x00000001113424d2 CFRunLoopRunSpecific + 626
27 GraphicsServices 0x000000011971b2fe GSEventRunModal + 65
28 UIKitCore 0x0000000115d2bfc2 UIApplicationMain + 140
29 App Name 0x000000010c0a976b main + 75
30 libdyld.dylib 0x000000011238e541 start + 1
31 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
JSON Response is like this
["Title": [ "S", "Y", "H", "Q", "M" ]]
My Model is like this
class TermList : Object, Mappable {
#objc dynamic var mainTerm : String?
var payingTerm = [String]?
required convenience init?(map: Map) {
self.init()
}
func mapping(map: Map) {
mainTerm <- map["MainTerm"]
payingTerm <- map["PayingTerm"]
}
}
I have been developing framework, I have used tab menu using carbonKit cocoapods, Now i'm trying to navigate UIVIewController xib.
When UITabBarController loaded the carbonkit menu default tab menu will be called.
Here is the code used for load xib UIViewcontroller
public func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {
print("called carbonkit")
print("carbon kit index 0 called")
return (UINib(nibName: "FirstViewController", bundle: Bundle(for: FirstViewController.self)).instantiate(withOwner: nil, options: nil).first as? FirstViewController)!
}
Here is the console output:
Called tab
called carbonkit
carbon kit index 0 called
2019-11-12 22:13:02.350434+0530 A8FlowSampleApp[41059:1971714] ***
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<NSObject 0x600000b1c8b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23c4f02e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50b97b20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23c4ebf9 -[NSException raise] + 9
3 Foundation 0x00007fff256f2ef3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 325
4 UIKitCore 0x00007fff474b9a52 -[UIRuntimeOutletConnection connect] + 109
5 CoreFoundation 0x00007fff23c3b052 -[NSArray makeObjectsPerformSelector:] + 242
6 UIKitCore 0x00007fff474b6bfa -[UINib instantiateWithOwner:options:] + 2190
7 A8Flow 0x0000000104db51d8 $s6A8Flow6MyTaskC24carbonTabSwipeNavigation_16viewControllerAtSo06UIViewJ0CSo06CarbonfgH0C_SutF + 1016
8 A8Flow 0x0000000104db546d $s6A8Flow6MyTaskC24carbonTabSwipeNavigation_16viewControllerAtSo06UIViewJ0CSo06CarbonfgH0C_SutFTo + 77
9 CarbonKit 0x00000001048c1d31 -[CarbonTabSwipeNavigation viewControllerAtIndex:] + 593
10 CarbonKit 0x00000001048c18fb -[CarbonTabSwipeNavigation loadFirstViewController] + 411
11 CarbonKit 0x00000001048bc90e -[CarbonTabSwipeNavigation initWithItems:delegate:] + 350
12 A8Flow 0x0000000104db69f2 $sSo24CarbonTabSwipeNavigationC5items8delegateABSayypGSg_yptcfcTO + 242
13 A8Flow 0x0000000104db4bc2 $sSo24CarbonTabSwipeNavigationC5items8delegateABSayypGSg_yptcfC + 50
14 A8Flow 0x0000000104db40ba $s6A8Flow6MyTaskC11viewDidLoadyyF + 378
15 A8Flow 0x0000000104db4dcb $s6A8Flow6MyTaskC11viewDidLoadyyFTo + 43
16 UIKitCore 0x00007fff471cdb45 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83
17 UIKitCore 0x00007fff471d2a9e -[UIViewController loadViewIfRequired] + 1084
18 UIKitCore 0x00007fff47136b8c -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 160
19 UIKitCore 0x00007fff47136e8c -[UINavigationController _startTransition:fromViewController:toViewController:] + 140
20 UIKitCore 0x00007fff47137d56 -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
21 UIKitCore 0x00007fff471390c1 -[UINavigationController __viewWillLayoutSubviews] + 150
22 UIKitCore 0x00007fff47119ef7 -[UILayoutContainerView layoutSubviews] + 217
23 UIKitCore 0x00007fff47d34cfd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478
24 QuartzCore 0x00007fff2b138d41 -[CALayer layoutSublayers] + 255
25 QuartzCore 0x00007fff2b13ef33 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 517
26 QuartzCore 0x00007fff2b14a86a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
27 QuartzCore 0x00007fff2b0917c8 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
28 QuartzCore 0x00007fff2b0c6ad1 _ZN2CA11Transaction6commitEv + 643
29 UIKitCore 0x00007fff47867481 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 81
30 CoreFoundation 0x00007fff23bb204c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
31 CoreFoundation 0x00007fff23bb17b8 __CFRunLoopDoBlocks + 312
32 CoreFoundation 0x00007fff23bac644
__CFRunLoopRun + 1284
33 CoreFoundation 0x00007fff23babe16
CFRunLoopRunSpecific + 438
34 GraphicsServices 0x00007fff38438bb0
GSEventRunModal + 65
35 UIKitCore 0x00007fff4784fb68
UIApplicationMain + 1621
36 A8FlowSampleApp 0x000000010458a6bb main + 75
37 libdyld.dylib 0x00007fff51a1dc25 start + 1
38 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type
NSException
(lldb)
Any help much appreciated pls.. tried lot ways to achieve it but could not make it.
Fixed myself
func firstView() -> UIViewController {
let cont = FirstViewController()
self.tabContView?.addChild(cont)
self.tabContView?.view.addSubview(cont.view)
cont.didMove(toParent: tabContView)
return cont
}
public func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {
print("called carbonkit")
print("carbon kit index 0 called")
return firstView()
}
Code:
NSString *Query=[NSString stringWithFormat:#"select *from peopleinfm where peopleinfmID=%d",TextEdit];
NSArray *Results=[[NSArray alloc]initWithArray:[DBManger loadDataFromDB:Query]];
self.FirstnameText.text=[[Results objectAtIndex:1]objectAtIndex:[self.DBManger.ColumnArray indexOfObject:#"firstname"]];
self.LastnameText.text=[[Results objectAtIndex:1]objectAtIndex:[self.DBManger.ColumnArray indexOfObject:#"lastname"]];
self.AgeText.text=[[Results objectAtIndex:1]objectAtIndex:[self.DBManger.ColumnArray indexOfObject:#"age"]];
Logs:
2016-02-12 19:03:36.068 SampleFMDB[9641:762577] no such table: peopleinfm
2016-02-12 19:03:36.077 SampleFMDB[9641:762577] _UIConstraintBasedLayoutLogUnsatisfiable is OFF
2016-02-12 19:03:37.934 SampleFMDB[9641:762577] no such table: peopleinfm
2016-02-12 19:03:37.978 SampleFMDB[9641:762577] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 1 beyond bounds for empty NSArray'
*** First throw call stack:
(
0 CoreFoundation 0x00b23a94 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x005e2e02 objc_exception_throw + 50
2 CoreFoundation 0x00aca4a0 __CFArrayGetTypeID_block_invoke + 0
3 SampleFMDB 0x00010003 -[AddViewController loadInfoToEdit] + 291
4 SampleFMDB 0x0000f9bc -[AddViewController viewDidLoad] + 396
5 UIKit 0x01070d74 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 44
6 UIKit 0x010758c2 -[UIViewController loadViewIfRequired] + 1556
7 UIKit 0x0107bf0e -[UIViewController __viewWillAppear:] + 114
8 UIKit 0x0109ecf0 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 202
9 UIKit 0x010b0d63 -[UINavigationController _startCustomTransition:] + 1375
10 UIKit 0x010c1c0b -[UINavigationController _startDeferredTransitionIfNeeded:] + 801
11 UIKit 0x010c2d05 -[UINavigationController __viewWillLayoutSubviews] + 68
12 UIKit 0x0128cd9f -[UILayoutContainerView layoutSubviews] + 252
13 UIKit 0x00f7916b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 813
14 libobjc.A.dylib 0x005f7059 -[NSObject performSelector:withObject:] + 70
15 QuartzCore 0x048ae60c -[CALayer layoutSublayers] + 144
16 QuartzCore 0x048a228e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
17 QuartzCore 0x048a20f2 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
18 QuartzCore 0x04894c2b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
19 QuartzCore 0x048c8c23 _ZN2CA11Transaction6commitEv + 589
20 QuartzCore 0x048ca484 _ZN2CA11Transaction17flush_transactionEv + 50
21 UIKit 0x00eadb55 _UIApplicationHandleEventQueue + 7921
22 CoreFoundation 0x00a3de7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
23 CoreFoundation 0x00a33b0b __CFRunLoopDoSources0 + 523
24 CoreFoundation 0x00a32f28 __CFRunLoopRun + 1032
25 CoreFoundation 0x00a32866 CFRunLoopRunSpecific + 470
26 CoreFoundation 0x00a3267b CFRunLoopRunInMode + 123
27 GraphicsServices 0x04148664 GSEventRunModal + 192
28 GraphicsServices 0x041484a1 GSEventRun + 104
29 UIKit 0x00eb3cc1 UIApplicationMain + 160
30 SampleFMDB 0x000108ea main + 138
31 libdyld.dylib 0x030f6a21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I am trying to statically blur an UIImage using the method below:
func blurImage(image: UIImage!, blurLevel: CGFloat!) -> UIImage! {
if self.context == nil {
self.context = CIContext();
}
let inputImage = CIImage(image: image);
let filter = CIFilter(name: "CIGaussianBlur");
filter.setValue(image, forKey: kCIInputImageKey);
filter.setValue(blurLevel, forKey: kCIInputRadiusKey);
let outputImage = filter.valueForKey(kCIOutputImageKey) as CIImage;
let outImage = self.context?.createCGImage(outputImage, fromRect: outputImage.extent());
return UIImage(CGImage: outImage)!;
}
But the debugger immediately raises an exception on filter.valueForKey(kCIOutputImageKey), confirmed by trying to print the object in the LLDB debugger:
-[UIImage _internalRepresentation]: unrecognized selector sent to instance 0x7fef33e89b00
Does anyone know why this exception is surfacing? I've tried different variations of the method to no avail as per various stack overflow questions, but I can't seem to figure this out...
I suspect it may just be a just a bug on Apple's part after more investigation, but if anyone has encountered this before help is appreciated
Stacktrace
2015-03-09 19:34:14.502 Rocks[3346:511164] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage _internalRepresentation]: unrecognized selector sent to instance 0x7fef33e89b00'
*** First throw call stack:
(
0 CoreFoundation 0x0000000112106f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000111d9fbb7 objc_exception_throw + 45
2 CoreFoundation 0x000000011210e04d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000011206627c ___forwarding___ + 988
4 CoreFoundation 0x0000000112065e18 _CF_forwarding_prep_0 + 120
5 CoreImage 0x000000011192cef7 -[CIGaussianBlur outputImage] + 108
6 Foundation 0x000000010f939823 -[NSObject(NSKeyValueCoding) valueForKey:] + 251
7 Rocks 0x000000010f588024 _TFC4Rocks23LocalCollectionViewCell9blurImagefS0_FTGSQCSo7UIImage_9blurLevelGSQV12CoreGraphics7CGFloat__GSQS1__ + 3284
8 Rocks 0x000000010f589538 _TFC4Rocks23LocalCollectionViewCell31requestCellProfilePictureChangefS0_FGSQPSs9AnyObject__T_ + 3544
9 Rocks 0x000000010f58450c _TFC4Rocks29LocalCollectionViewController14collectionViewfS0_FTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 860
10 Rocks 0x000000010f584b6f _TToFC4Rocks29LocalCollectionViewController14collectionViewfS0_FTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 79
11 UIKit 0x0000000110bea41b -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 244
12 UIKit 0x0000000110bebb54 -[UICollectionView _updateVisibleCellsNow:] + 3445
13 UIKit 0x0000000110bef801 -[UICollectionView layoutSubviews] + 243
14 UIKit 0x0000000110635973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
15 QuartzCore 0x00000001103a0de8 -[CALayer layoutSublayers] + 150
16 QuartzCore 0x0000000110395a0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
17 QuartzCore 0x000000011039587e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
18 QuartzCore 0x000000011030363e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
19 QuartzCore 0x000000011030474a _ZN2CA11Transaction6commitEv + 390
20 UIKit 0x00000001105ba54d -[UIApplication _reportMainSceneUpdateFinished:] + 44
21 UIKit 0x00000001105bb238 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2642
22 UIKit 0x00000001105b9bf2 -[UIApplication workspaceDidEndTransaction:] + 179
23 FrontBoardServices 0x0000000115f0b2a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
24 CoreFoundation 0x000000011203c53c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
25 CoreFoundation 0x0000000112032285 __CFRunLoopDoBlocks + 341
26 CoreFoundation 0x0000000112032045 __CFRunLoopRun + 2389
27 CoreFoundation 0x0000000112031486 CFRunLoopRunSpecific + 470
28 UIKit 0x00000001105b9669 -[UIApplication _run] + 413
29 UIKit 0x00000001105bc420 UIApplicationMain + 1282
30 Rocks 0x000000010f59262e top_level_code + 78
31 Rocks 0x000000010f59266a main + 42
32 libdyld.dylib 0x0000000112bb8145 start + 1
33 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I am getting the error [__NSCFArray objectForKey:]: unrecognized selector sent to instance when trying to fetch some data from my Core Data.
I am relatively new to iOS programming and don't quite understand what this error is trying to tell me. I set an exception breakpoint to figure out which line is giving me the problem and it is this line of code:
if let fetchResults = managedObjectContext!.executeFetchRequest(fetchRequest, error: nil) as? [User] {
Why am I getting this error and how do I resolve it? Is this related to the way I save my Core Data? I just recently did a change where I receive a JSON from the server, then process in the background and then finally save changes to my ManagedObjectContext in the main thread.
func getUser(userId: String) -> User? {
let fetchRequest = NSFetchRequest(entityName: "User")
fetchRequest.predicate = NSPredicate(format: "userId == %#", userId)
fetchRequest.fetchLimit = 1
if let fetchResults = managedObjectContext!.executeFetchRequest(fetchRequest, error: nil) as? [User] {
if !fetchResults.isEmpty {
return fetchResults[0]
}
else {
println("UserId \(userId) not in database")
}
}
return nil
}
Error
2014-12-06 13:09:36.087 LFDate[3162:51570] -[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x7fb9e95c4310
2014-12-06 13:09:36.090 LFDate[3162:51570] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x7fb9e95c4310'
*** First throw call stack:
(
0 CoreFoundation 0x00000001025c2f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010465ebb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001025ca04d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010252227c ___forwarding___ + 988
4 CoreFoundation 0x0000000102521e18 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x000000010248beaf CFDictionaryGetValue + 159
6 Foundation 0x0000000102befd78 -[NSKeyedUnarchiver initForReadingWithData:] + 1698
7 Foundation 0x0000000102c135ea +[NSKeyedUnarchiver unarchiveObjectWithData:] + 66
8 CoreData 0x000000010210b4e0 _prepareResultsFromResultSet + 3552
9 CoreData 0x0000000102108930 newFetchedRowsForFetchPlan_MT + 3296
10 CoreData 0x00000001020f53ac -[NSSQLCore objectsForFetchRequest:inContext:] + 524
11 CoreData 0x00000001020f4e2b -[NSSQLCore executeRequest:withContext:error:] + 299
12 CoreData 0x00000001021ca4f3 __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 3331
13 CoreData 0x00000001021d27ee gutsOfBlockToNSPersistentStoreCoordinatorPerform + 190
14 libdispatch.dylib 0x00000001052117f4 _dispatch_client_callout + 8
15 libdispatch.dylib 0x00000001051f8774 _dispatch_barrier_sync_f_invoke + 365
16 CoreData 0x00000001021c53d5 _perform + 197
17 CoreData 0x00000001020f4ac8 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 504
18 CoreData 0x00000001020f33e0 -[NSManagedObjectContext executeFetchRequest:error:] + 544
19 LFDate 0x0000000101b9c3b3 _TFC6LFDate14DatabaseHelper7getUserfS0_FSSGSqCS_4User_ + 1075
20 LFDate 0x0000000101c4ce01 _TFC6LFDate23MenuTableViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 4689
21 LFDate 0x0000000101c4e4ff _TToFC6LFDate23MenuTableViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 79
22 UIKit 0x000000010349d4b3 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
23 UIKit 0x000000010347cfb1 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2846
24 UIKit 0x0000000103492e3c -[UITableView layoutSubviews] + 213
25 UIKit 0x000000010341f973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
26 QuartzCore 0x000000010318ade8 -[CALayer layoutSublayers] + 150
27 QuartzCore 0x000000010317fa0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
28 QuartzCore 0x000000010317f87e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
29 QuartzCore 0x00000001030ed63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
30 QuartzCore 0x00000001030ee74a _ZN2CA11Transaction6commitEv + 390
31 QuartzCore 0x00000001030eedb5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
32 CoreFoundation 0x00000001024f7dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
33 CoreFoundation 0x00000001024f7d20 __CFRunLoopDoObservers + 368
34 CoreFoundation 0x00000001024edb53 __CFRunLoopRun + 1123
35 CoreFoundation 0x00000001024ed486 CFRunLoopRunSpecific + 470
36 GraphicsServices 0x00000001072f09f0 GSEventRunModal + 161
37 UIKit 0x00000001033a6420 UIApplicationMain + 1282
38 LFDate 0x0000000101be33ae top_level_code + 78
39 LFDate 0x0000000101be33ea main + 42
40 libdyld.dylib 0x0000000105246145 start + 1
41 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException