代码之家  ›  专栏  ›  技术社区  ›  Alexsander Akers

ASIFormDataRequest错误

  •  0
  • Alexsander Akers  · 技术社区  · 14 年前
    - (void) recordTransaction: (SKPaymentTransaction *) transaction {
        NSDictionary * receipt = [transaction.transactionReceipt dictionaryFromAppleResponse];
        NSDictionary * purchaseInfo = [[NSData dataFromBase64String: [receipt objectForKey: @"purchase-info"]] dictionaryFromAppleResponse];
    
        NSURL * url = [NSURL URLWithString: @"http://..."];
    
        ASIFormDataRequest * request = [ASIFormDataRequest requestWithURL: url];
        [request setDelegate: self];
    
        [request setPostValue: [NSNumber numberWithBool: YES] forKey: @"upload"];
        [request setPostValue: [[[NSBundle mainBundle] infoDictionary] objectForKey: @"CFBundleDisplayName"] forKey: @"app_id"];
        [request setPostValue: [receipt descriptionInStringsFileFormat] forKey: @"receipt"];
        [request setPostValue: [purchaseInfo descriptionInStringsFileFormat] forKey: @"purchase_info"];
    
        [WTFeedbackView switchToProgressView];
        [request setUploadProgressDelegate: [WTFeedbackView class]];
    
        NSLog(@"Before -startAsynchronous call.");
        [request startAsynchronous];
        NSLog(@"After  -startAsynchronous call.");
    }
    

    操作文件数据 -dictionaryFromAppleResponse 返回一个 NSDictionary . 我不明白为什么会出现以下错误:

    Error Domain=ASIHTTPRequestErrorDomain Code=10 "NSInvalidArgumentException" UserInfo=0x19eb00 {NSLocalizedFailureReason=+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil, NSUnderlyingError=0x19eae0 "The operation couldn’t be completed. (ASIHTTPRequestErrorDomain error 10.)", NSLocalizedDescription=NSInvalidArgumentException}
    
    1 回复  |  直到 14 年前
        1
  •  0
  •   JosephH    14 年前

    如果您在objc\u exception\u throw上添加断点,这将有助于您获得更多关于它到底哪里出错的信息(如果这样做了,请向问题添加回溯)。

    假设错误来自ASIHTTPRequest本身,它使用NSInvocation与它的委托进行通信。我怀疑你代码里的这一行:

    [request setUploadProgressDelegate: [WTFeedbackView class]];
    

    我不确定是否可以将progress委托设置为类,我一直认为它必须是一个实际的对象—也许尝试删除它,我怀疑它会使错误消失。