gpt4 book ai didi

ios - AWS batchGetItem NSInvalidArgumentException JSONKeyPathsByPropertyKey:无法识别的选择器

转载 作者:行者123 更新时间:2023-11-28 21:53:05 25 4
gpt4 key购买 nike

我正在尝试从Swift应用程序中的DynamoDB获取一些行。在下面代码的最后一行,我得到一个NSInvalidArgumentException。我认为一定是因为我的请求格式不正确,但是我不知道出了什么问题。在Java sdk的文档(batch operation sample)中,它们使用TableKeysAndAttributes,而iOS SDK中似乎不存在。

这是我的代码:

 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


这是错误:

2014-12-18 13:23:17.002 TouchDashboard [8066:503166] + [NSDictionaryI JSONKeyPathsByPropertyKey]:无法识别的选择器已发送给类0x10a9930e8
2014-12-18 13:23:17.010 TouchDashboard [8066:503166] ***由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'+ [__ NSDictionaryI JSONKeyPathsByPropertyKey]:无法识别的选择器已发送给类0x10a9930e8'
***首先抛出调用堆栈:

    0 CoreFoundation 0x000000010a6ebf35 __exceptionPreprocess + 165
    1个libobjc.A.dylib 0x000000010c5b1bb7 objc_exception_throw + 45
    2 CoreFoundation 0x000000010a6f2f4d + [NSObject(NSObject)didNotRecognizeSelector:] + 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视图] + 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-[UIApplicationworkspaceDidEndTransaction:] + 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主+ 42
    37 libdyld.dylib 0x000000010cd8b145开始+ 1
    38 ??? 0x0000000000000001 0x0 + 1

最佳答案

AWSDynamoDBBatchGetItemInputrequestItems属性必须是以下键/值对的字典:

NSString(表名):AWSDynamoDBKeysAndAttributesKeysAndAttributes

当前,您正在传递NSDictionary的实例作为值。将代码段更新为使用AWSDynamoDBKeysAndAttributes后,它应该可以工作。

关于ios - AWS batchGetItem NSInvalidArgumentException JSONKeyPathsByPropertyKey:无法识别的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27553272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com