How to check for nil on a Realm Results array value - ios

I'm trying to figure out why I cannot check for nil on the following function call:
var allExercises : Results<Exercises>?
var exerciseIndex : Int = 0
#objc func goToNextExercise(){
if allExercises?[exerciseIndex] != nil {
print("Does not equal nil")
exerciseIndex += 1
} else {
print("Does equal nil")
}
}
When allExercises?[exerciseIndex] does equal nil, the application crashes and I get an "indexPath out of Range" error:
*** Terminating app due to uncaught exception 'RLMException', reason: 'Index 3 is out of bounds (must be less than 3).'
*** First throw call stack:
(
0 CoreFoundation 0x0000000104a7127e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00000001048deb20 objc_exception_throw + 48
2 SectionRowsTutorial 0x00000001025d7aae _Z20RLMThrowResultsErrorP8NSString + 670
3 SectionRowsTutorial 0x00000001025d8cc6 _ZL25translateRLMResultsErrorsIZ28-[RLMResults objectAtIndex:]E3$_6EDaOT_P8NSString + 118
4 SectionRowsTutorial 0x00000001025d8bf4 -[RLMResults objectAtIndex:] + 100
5 SectionRowsTutorial 0x000000010278c9dc $s10RealmSwift7ResultsVyxSicig + 236
6 SectionRowsTutorial 0x00000001022dc576 $s19SectionRowsTutorial19ThirdViewControllerC16goToNextExerciseyyF + 246
7 SectionRowsTutorial 0x00000001022dc87b $s19SectionRowsTutorial19ThirdViewControllerC16goToNextExerciseyyFTo + 43
8 UIKitCore 0x0000000108571fff -[UIApplication sendAction:to:from:forEvent:] + 83
9 UIKitCore 0x0000000107f4a00e -[UIControl sendAction:to:forEvent:] + 223
10 UIKitCore 0x0000000107f4a358 -[UIControl _sendActionsForEvents:withEvent:] + 398
11 UIKitCore 0x0000000107f492b7 -[UIControl touchesEnded:withEvent:] + 481
12 UIKitCore 0x00000001085acbbf -[UIWindow _sendTouchesForEvent:] + 2604
13 UIKitCore 0x00000001085ae4c6 -[UIWindow sendEvent:] + 4596
14 UIKitCore 0x000000010858953b -[UIApplication sendEvent:] + 356
15 UIKitCore 0x000000010860a71a __dispatchPreprocessedEventFromEventQueue + 6847
16 UIKitCore 0x000000010860d1e0 __handleEventQueueInternal + 5980
17 CoreFoundation 0x00000001049d4471 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
18 CoreFoundation 0x00000001049d439c __CFRunLoopDoSource0 + 76
19 CoreFoundation 0x00000001049d3b74 __CFRunLoopDoSources0 + 180
20 CoreFoundation 0x00000001049ce87f __CFRunLoopRun + 1263
21 CoreFoundation 0x00000001049ce066 CFRunLoopRunSpecific + 438
22 GraphicsServices 0x000000010e756bb0 GSEventRunModal + 65
23 UIKitCore 0x0000000108570d4d UIApplicationMain + 1621
24 SectionRowsTutorial 0x00000001022e759b main + 75
25 libdyld.dylib 0x0000000105ba4c25 start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

You are checking the value of allExercises, if you pass a greater index than the array size, it's crashing. for check, you should first check if exerciseIndex is less than allExercises count - 1 and then check data
if exerciseIndex <= allExercises.count - 1

Related

NSInvalidArgumentException - Attempt to insert nil object from objects

I had the error below:
'*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]'
it happens when I try to save texts from textfields using saveInBackground or other kind of saving method of Parse. Because code is little, all code is pasted below:
#IBAction func onSave(_ sender: Any) {
let profile = PFObject(className: "Info")
profile["preferredName"] = nameTextField.text!
profile["major"] = majorTextField.text!
profile["introduction"] = bioTextView.text!
let segmentIndex = yearSegmented.selectedSegmentIndex
UserDefaults.standard.set(segmentIndex, forKey: "segmentIndex")
profile["year"] = yearSegmented.titleForSegment(at: segmentIndex)!
print(profile.allKeys) // print keys in profile
print(profile.value(forKey: "introduction")!, profile.value(forKey: "major")!,
profile.value(forKey: "year")!, profile.value(forKey: "preferredName")!) // print values in profile
profile.saveInBackground(block: { (success, error) in // line where the error happens
if success {
UserDefaults.standard.set(true, forKey: "hasProfile")
print("profile saved")
} else {
print("failed to save profile")
}
})
This is how Parse IOS Guide told me about how to save objects:
let gameScore = PFObject(className:"GameScore")
gameScore["score"] = 1337
gameScore["playerName"] = "Sean Plott"
gameScore["cheatMode"] = false
gameScore.saveInBackground { (succeeded, error) in
if (succeeded) {
// The object has been saved.
} else {
// There was a problem, check error.description
}
}
I tested if any content in profile is nil, but all keys and values are there and can be printed. I don't see anything nil here, so I cannot understand this error. If anyone could shed some light to enlighten me, I would be be very grateful for this.
In case anyone needs the stack trace:
0 CoreFoundation 0x00000001803f25e4 __exceptionPreprocess + 236
1 libobjc.A.dylib 0x000000018019813c objc_exception_throw + 56
2 CoreFoundation 0x00000001804775b4 -[__NSCFString characterAtIndex:].cold.1 + 0
3 CoreFoundation 0x0000000180474fc4 -[__NSPlaceholderArray initWithCapacity:].cold.1 + 0
4 CoreFoundation 0x00000001802ef138 -[__NSPlaceholderArray initWithObjects:count:] + 184
5 CoreFoundation 0x00000001803dddec +[NSArray arrayWithObjects:count:] + 44
6 Parse 0x0000000104eda478 -[PFTaskQueue enqueue:] + 380
7 Parse 0x0000000104e78b2c -[PFObject saveInBackground] + 148
8 Parse 0x0000000104e78c1c -[PFObject saveInBackgroundWithBlock:] + 68
9 StudyMate 0x00000001041c59bc $s9StudyMate18EditViewControllerC6onSaveyyypF + 7276
10 StudyMate 0x00000001041c5fe4 $s9StudyMate18EditViewControllerC6onSaveyyypFTo + 68
11 UIKitCore 0x0000000184d81fa0 -[UIApplication sendAction:to:from:forEvent:] + 96
12 UIKitCore 0x00000001842a7714 -[UIBarButtonItem _triggerActionForEvent:] + 176
13 UIKitCore 0x000000018427fe24 __45-[_UIButtonBarTargetAction _invoke:forEvent:]_block_invoke + 36
14 UIKitCore 0x000000018427fcd8 -[_UIButtonBarTargetAction _invoke:forEvent:] + 168
15 UIKitCore 0x0000000184d81fa0 -[UIApplication sendAction:to:from:forEvent:] + 96
16 UIKitCore 0x0000000184680bd8 -[UIControl sendAction:to:forEvent:] + 124
17 UIKitCore 0x0000000184680fc0 -[UIControl _sendActionsForEvents:withEvent:] + 352
18 UIKitCore 0x0000000184681010 -[UIControl _sendActionsForEvents:withEvent:] + 432
19 UIKitCore 0x000000018467f8e8 -[UIControl touchesEnded:withEvent:] + 516
20 UIKitCore 0x0000000184dc0af0 -[UIWindow _sendTouchesForEvent:] + 1104
21 UIKitCore 0x0000000184dc25d4 -[UIWindow sendEvent:] + 4332
22 UIKitCore 0x0000000184d9a390 -[UIApplication sendEvent:] + 784
23 UIKitCore 0x0000000184e286f4 __dispatchPreprocessedEventFromEventQueue + 7520
24 UIKitCore 0x0000000184e2a770 __processEventQueue + 6764
25 UIKitCore 0x0000000184e22760 __eventFetcherSourceCallback + 184
26 CoreFoundation 0x0000000180360820 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
27 CoreFoundation 0x0000000180360720 __CFRunLoopDoSource0 + 204
28 CoreFoundation 0x000000018035fab0 __CFRunLoopDoSources0 + 256
29 CoreFoundation 0x000000018035a004 __CFRunLoopRun + 744
30 CoreFoundation 0x0000000180359804 CFRunLoopRunSpecific + 572
31 GraphicsServices 0x000000018c23660c GSEventRunModal + 160
32 UIKitCore 0x0000000184d7bd2c -[UIApplication _run] + 992
33 UIKitCore 0x0000000184d808c8 UIApplicationMain + 112
34 libswiftUIKit.dylib 0x00000001b6766224 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 100
35 StudyMate 0x00000001041c7a9c $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
36 StudyMate 0x00000001041c7a24 $s9StudyMate11AppDelegateC5$mainyyFZ + 44
37 StudyMate 0x00000001041c7b20 main + 28
38 dyld 0x0000000104501cd8 start_sim + 20
39 ??? 0x0000000104451088 0x0 + 4366602376
40 ??? 0xb23a000000000000 0x0 + 12842577287400390656

How to save [String] to Realm

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"]
}
}

App crashes when keyboard is numberPad, phonePad or decimalPad (iOS 12.2, Xcode 10.2)

My app has suddenly started crashing when keyboard type is numberPad or phonePad. The crash happen in simulator and device both. I am setting keyboard type by below code.
self.textFieldMobileNumber.keyboardType = .numberPad
Default keyboard just works fine. The crash log is blow
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSSetM addObject:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x0000000112d0f6fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000112051ac5 objc_exception_throw + 48
2 CoreFoundation 0x0000000112c5dddc _CFThrowFormattedException + 194
3 CoreFoundation 0x0000000112c81601 -[__NSSetM addObject:] + 817
4 UIKitCore 0x000000011ca49f8f +[UIKeyboardImpl uniqueNumberPadInputModesFromInputModes:forKeyboardType:] + 1257
5 UIKitCore 0x000000011ca4998f -[UIKeyboardImpl desirableInputModesWithExtensions:] + 1446
6 UIKitCore 0x000000011ca4a0cf -[UIKeyboardImpl recomputeActiveInputModesWithExtensions:] + 54
7 UIKitCore 0x000000011ca3b158 -[UIKeyboardImpl setDelegate:force:] + 3343
8 UIKitCore 0x000000011ca8db1e -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1506
9 UIKitCore 0x000000011cc4d417 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 81
10 UIKitCore 0x000000011cc4916a -[UIResponder becomeFirstResponder] + 865
11 UIKitCore 0x000000011d0d4fb8 -[UIView(Hierarchy) becomeFirstResponder] + 145
12 UIKitCore 0x000000011cf269ec -[UITextField becomeFirstResponder] + 237
13 UIKitCore 0x000000011cee67a5 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 208
14 UIKitCore 0x000000011ced3853 -[UITextSelectionInteraction oneFingerTap:] + 3851
15 UIKitCore 0x000000011c80714d -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
16 UIKitCore 0x000000011c80fc69 _UIGestureRecognizerSendTargetActions + 109
17 UIKitCore 0x000000011c80d5ba _UIGestureRecognizerSendActions + 311
18 UIKitCore 0x000000011c80c897 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 966
19 UIKitCore 0x000000011c7fec4e _UIGestureEnvironmentUpdate + 2820
20 UIKitCore 0x000000011c7fe108 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 478
21 UIKitCore 0x000000011c7fde96 -[UIGestureEnvironment _updateForEvent:window:] + 200
22 UIKitCore 0x000000011cc595bc -[UIWindow sendEvent:] + 4057
23 UIKitCore 0x000000011cc37d16 -[UIApplication sendEvent:] + 356
24 UIKitCore 0x000000011cd08293 __dispatchPreprocessedEventFromEventQueue + 3232
25 UIKitCore 0x000000011cd0abb9 __handleEventQueueInternal + 5911
26 CoreFoundation 0x0000000112c76be1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
27 CoreFoundation 0x0000000112c76463 __CFRunLoopDoSources0 + 243
28 CoreFoundation 0x0000000112c70b1f __CFRunLoopRun + 1231
29 CoreFoundation 0x0000000112c70302 CFRunLoopRunSpecific + 626
30 GraphicsServices 0x00000001171ab2fe GSEventRunModal + 65
31 UIKitCore 0x000000011cc1dba2 UIApplicationMain + 140
32 IMRide 0x000000010b39beb8 main + 72
33 libdyld.dylib 0x000000011560a541 start + 1
34 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I have searched all over the internet and tried many solution from my side but the issue did not fix.
Edit
When I set default keyboard. It shows (null) for number keyboard, switching to that does not crash but when set .numberPad keyboard it starts crashing.
Check the image below for the reference
Finally I found the issue. I had overridden a method of NumberFormatter which caused the crash while showing numberPad keyboard.
Below is the method that I override which should not have been done, or done in some other way.
extension NumberFormatter {
open override func string(for obj: Any?) -> String? {
if condition {
return <some value based on condition>
}
return nil
}
}
Returning nil caused the crash. Also if you return something else rather then the obj it will print the same in keyboard keys.

Sharing using Facebook dialog

let content: FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: "https://www.google.com")
content.contentTitle = "ContentTitle"
content.contentDescription = "ContentDescription"
let shareDialog = FBSDKShareDialog();
shareDialog.mode = .Browser
shareDialog.shareContent = content
shareDialog.show()
This is the code I used to share.
While sharing i getting the crash like below
'NSInvalidArgumentException', reason: '-[FBSDKApplicationDelegate openBridgeAPIRequest:useSafariViewController:fromViewController:completionBlock:]: unrecognized selector sent to instance 0x7fa69031c9d0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c2f1e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010bcd8deb objc_exception_throw + 48
2 CoreFoundation 0x000000010c2fa48d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010c24790a ___forwarding___ + 970
4 CoreFoundation 0x000000010c2474b8 _CF_forwarding_prep_0 + 120
5 Store 0x000000010a42a858 -[FBSDKShareDialog _showBrowser:] + 417
6 Store 0x000000010a4297c8 -[FBSDKShareDialog show] + 327
7 Store 0x000000010a351d47 _TFC5Store25StorePlayerViewController17didTapShareButtonfS0_FSiT_ + 1847
8 Store 0x000000010a351e6a _TToFC5Store25StorePlayerViewController17didTapShareButtonfS0_FSiT_ + 42
9 Store 0x000000010a35acb0 _TTDFC5Store25StorePlayerViewController17didTapShareButtonfS0_FSiT_ + 48
10 Store 0x000000010a35231d _TTWC5Store25StorePlayerViewControllerS_31DopeMeterViewControllerDelegateS_FS1_17didTapShareButtonuRq_S1__fq_FSiT_ + 45
11 Store 0x000000010a3e24c9 _TFC5Store23DopeMeterViewController12OnShareClickfS0_FCSo8UIButtonT_ + 201
12 Store 0x000000010a3e254a _TToFC5Store23DopeMeterViewController12OnShareClickfS0_FCSo8UIButtonT_ + 58
13 UIKit 0x000000010c6a1194 -[UIApplication sendAction:to:from:forEvent:] + 92
14 UIKit 0x000000010c8106fc -[UIControl sendAction:to:forEvent:] + 67
15 UIKit 0x000000010c8109c8 -[UIControl _sendActionsForEvents:withEvent:] + 311
16 UIKit 0x000000010c80faf8 -[UIControl touchesEnded:withEvent:] + 601
17 UIKit 0x000000010c71049b -[UIWindow _sendTouchesForEvent:] + 835
18 UIKit 0x000000010c7111d0 -[UIWindow sendEvent:] + 865
19 UIKit 0x000000010c6bfb66 -[UIApplication sendEvent:] + 263
20 UIKit 0x000000010c699d97 _UIApplicationHandleEventQueue + 6844
21 CoreFoundation 0x000000010c21da31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 CoreFoundation 0x000000010c21395c __CFRunLoopDoSources0 + 556
23 CoreFoundation 0x000000010c212e13 __CFRunLoopRun + 867
24 CoreFoundation 0x000000010c212828 CFRunLoopRunSpecific + 488
25 GraphicsServices 0x000000010f640ad2 GSEventRunModal + 161
26 UIKit 0x000000010c69f610 UIApplicationMain + 171
27 doopaadoo 0x00000001090a019d main + 109
28 libdyld.dylib 0x0000000112cb192d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I search lot bt cant find any solution.

AWS batchGetItem NSInvalidArgumentException JSONKeyPathsByPropertyKey: unrecognized selector

I'm trying to get some rows from DynamoDB in a Swift application. At the very last line in my code below I get a NSInvalidArgumentException. I think it must be because my request is not formatted correctly, but I don't know what is wrong. In the docs (batch operation sample) for the java sdk they use TableKeysAndAttributes, which doesn't seem to exist in the iOS SDK.
Here is my code:
var venueIdAttribute = AWSDynamoDBAttributeValue()
venueIdAttribute.N = "2164156"
var venueIdCondition = AWSDynamoDBCondition()
venueIdCondition.comparisonOperator = .EQ // Hash Key must always be Equals
venueIdCondition.attributeValueList = [venueIdAttribute]
var startDateAttribute = AWSDynamoDBAttributeValue()
var startString = String(format:"%1.0f", lastSyncDate.timeIntervalSince1970 * 1000)
startDateAttribute.N = String(format:"%1.0f", lastSyncDate.timeIntervalSince1970 * 1000)
var dateCondition = AWSDynamoDBCondition()
dateCondition.comparisonOperator = .GT
dateCondition.attributeValueList = [startDateAttribute];
var keysArray : NSArray = [["venueId" : venueIdCondition, "dateInterval" : dateCondition]]
var tableDict : NSDictionary = ["Keys":keysArray]
var requestMap : NSDictionary = ["myTable":tableDict]
var request : AWSDynamoDBBatchGetItemInput = AWSDynamoDBBatchGetItemInput()
request.requestItems = requestMap
request.returnConsumedCapacity = AWSDynamoDBReturnConsumedCapacity.Total
var response : BFTask = dynamoDB.batchGetItem(request) // This is synchronous
Here is the error:
2014-12-18 13:23:17.002 TouchDashboard[8066:503166] +[NSDictionaryI JSONKeyPathsByPropertyKey]: unrecognized selector sent to class 0x10a9930e8
2014-12-18 13:23:17.010 TouchDashboard[8066:503166] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[__NSDictionaryI JSONKeyPathsByPropertyKey]: unrecognized selector sent to class 0x10a9930e8'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a6ebf35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c5b1bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010a6f2f4d +[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010a64b27c ___forwarding_ + 988
4 CoreFoundation 0x000000010a64ae18 _CF_forwarding_prep_0 + 120
5 TouchDashboard 0x0000000109b1176a -[MTLJSONAdapter initWithModel:] + 490
6 TouchDashboard 0x0000000109b0fc47 +[MTLJSONAdapter JSONDictionaryFromModel:] + 87
7 TouchDashboard 0x00000001099a47c5 +[AZModelUtility JSONDictionaryFromMapMTLDictionary:] + 517
8 TouchDashboard 0x0000000109a91c5b 59+[AWSDynamoDBBatchGetItemInput requestItemsJSONTransformer]_block_invoke_2 + 75
9 TouchDashboard 0x0000000109b21718 -[MTLReversibleValueTransformer reverseTransformedValue:] + 88
10 TouchDashboard 0x0000000109b11b90 __32-[MTLJSONAdapter JSONDictionary]_block_invoke + 480
11 CoreFoundation 0x000000010a62d766 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 102
12 CoreFoundation 0x000000010a62d66c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
13 TouchDashboard 0x0000000109b1192c -[MTLJSONAdapter JSONDictionary] + 300
14 TouchDashboard 0x0000000109b0fc5b +[MTLJSONAdapter JSONDictionaryFromModel:] + 107
15 TouchDashboard 0x00000001099a6829 -[AWSDynamoDB invokeRequest:HTTPMethod:URLString:targetPrefix:operationName:outputClass:] + 313
16 TouchDashboard 0x00000001099a6bd9 -[AWSDynamoDB batchGetItem:] + 153
17 TouchDashboard 0x000000010991a0d7 _TFC14TouchDashboard14ViewController9batchSyncfS0_FT_T_ + 10663
18 TouchDashboard 0x0000000109917349 _TFC14TouchDashboard14ViewController11viewDidLoadfS0_FT_T_ + 1161
19 TouchDashboard 0x0000000109917462 _TToFC14TouchDashboard14ViewController11viewDidLoadfS0_FT_T_ + 34
20 UIKit 0x000000010b41ea90 -[UIViewController loadViewIfRequired] + 738
21 UIKit 0x000000010b41ec8e -[UIViewController view] + 27
22 UIKit 0x000000010b33dca9 -[UIWindow addRootViewControllerViewIfPossible] + 58
23 UIKit 0x000000010b33e041 -[UIWindow _setHidden:forced:] + 247
24 UIKit 0x000000010b34a72c -[UIWindow makeKeyAndVisible] + 42
25 UIKit 0x000000010b2f5061 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2628
26 UIKit 0x000000010b2f7d2c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1350
27 UIKit 0x000000010b2f6bf2 -[UIApplication workspaceDidEndTransaction:] + 179
28 FrontBoardServices 0x000000010ebe92a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
29 CoreFoundation 0x000000010a62153c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 12
30 CoreFoundation 0x000000010a617285 __CFRunLoopDoBlocks + 341
31 CoreFoundation 0x000000010a616a43 __CFRunLoopRun + 851
32 CoreFoundation 0x000000010a616486 CFRunLoopRunSpecific + 470
33 UIKit 0x000000010b2f6669 -[UIApplication _run] + 413
34 UIKit 0x000000010b2f9420 UIApplicationMain + 1282
35 TouchDashboard 0x000000010992ba2e top_level_code + 78
36 TouchDashboard 0x000000010992ba6a main + 42
37 libdyld.dylib 0x000000010cd8b145 start + 1
38 ??? 0x0000000000000001 0x0 + 1
AWSDynamoDBBatchGetItemInput's requestItems property needs to be a dictionary of the following key/value pair:
NSString (a table name) : AWSDynamoDBKeysAndAttributes (KeysAndAttributes)
Currently, you are passing an instance of NSDictionary as a value. Once you update your code snippet to use AWSDynamoDBKeysAndAttributes, it should work.

Resources