views:

87

answers:

1
- (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];

    UIDevice * device = [UIDevice currentDevice];
    NSString * userAgent = [NSString stringWithFormat: @"Model: %@ (%@); System: %@ %@; Name: %@; UDID: %@", device.model, device.localizedModel, device.systemName, device.systemVersion, device.name, device.uniqueIdentifier];
    [request addRequestHeader: @"User-Agent" value: userAgent];

    [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.");
}

NSData -dictionaryFromAppleResponse returns an NSDictionary. I can't figure out why I'm getting the following error:

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}
A: 

If you add a breakpoint on objc_exception_throw, that should help you get more information about exactly where it is going wrong (and do add the backtrace to your question if you do).

Assuming the error is coming from ASIHTTPRequest itself, it uses NSInvocation for talking to it's delegate. I'm suspicious of this line from your code:

[request setUploadProgressDelegate: [WTFeedbackView class]];

I'm not sure you can set the progress delegate to be a class, I'd always presumed it has to be an actual object - perhaps try removing that, I suspect it will make the error go away.

JosephH
That might be it. I'm going to look into that class thing and get back to you.
Alexsander Akers