Pergunta

I am using Amazon SimpleDB for select queries, and I am trying to use the AWS AmazonServiceRequestDelegate, here are the delegate methods (I have conformed in .h BTW):

- (void)request:(AmazonServiceRequest *)request didFailWithError:(NSError *)error {

    NSLog(@"%@", error.localizedDescription);
}

- (void)request:(AmazonServiceRequest *)request didReceiveData:(NSData *)data {

    NSLog(@"recieving data");
}

- (void)request:(AmazonServiceRequest *)request didReceiveResponse:(NSURLResponse *)response {

    NSLog(@"response recieved");
}

- (void)request:(AmazonServiceRequest *)request didCompleteWithResponse:(AmazonServiceResponse *)response {

    NSLog(@"Completed");
}

They all get called except didCompleteWithResponse:, the method that is supposed to be called when the whole operation is completed with a response. didFailWithError: isn't getting called either, but I don't see any reason for my operation to fail anyways.

Here is my code to create the select query:

        SimpleDBSelectRequest *sReq = [[SimpleDBSelectRequest alloc] initWithSelectExpression:SELECT_STRING andConsistentRead: YES];

    sReq.delegate = self;

    sReq.requestTag = FIND_FRIENDS_SDB;

    [sdbClient select: sReq];

Where SELECT_STRING and FIND_FRIENDS_SDB are predefined and valid to the context strings.

What is my problem here? Thanks!

Update:

Got the delegating to work. Getting an error related to my SimpleDB SELECT queries, apparently the syntax for my SELECT expression is invalid. I get two errors, because I am doing two queries, here are the SELECT expressions for each:

select * from trvlogue-app where Type = 'account' AND itemName() = 'me%40rohankapur.com-account'

That is looking at the 'Type' attribute and 'itemName()' and checking if they equal to something in the domain.

select * from trvlogue-app where Email in('kate-bell%40mac.com','www.creative-consulting-inc.com','d-higgins%40mac.com','John-Appleseed%40mac.com','anna-haro%40mac.com','hank-zakroff%40mac.com')

That is checking if these strings are present in the Email attribute in the domain.

NOTE:

Fixed it, apparently when using SELECT expressions, domain names cannot have dashes. Or dashes seem to break the requests somehow

Foi útil?

Solução

When using AmazonServiceRequestDelegate, this blog post can be helpful. Basically, you need to:

  1. Avoid using AmazonServiceRequestDelegate in a background thread.
  2. Retain a strong reference to the client.
  3. Retain a strong reference to the delegate.

Also, you should make sure you called [AmazonErrorHandler shouldNotThrowExceptions] since you didn't implement request:didFailWithServiceException:. Please take a look at this blog post for the detail.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top