2013-01-17 59 views
1

我使用Amazon的SimpleDB为select查询,我试图使用AWS AmazonServiceRequestDelegate,这里是委托方法(我在.H符合BTW):AWS的iOS SDK的委托方法没有得到调用

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

除了didCompleteWithResponse:之外,它们全部被调用,这是在整个操作完成并响应时应该调用的方法。 didFailWithError:也没有被调用,但我没有看到我的操作失败的任何理由无论如何。

这里是我的代码来创建选择查询:

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

    sReq.delegate = self; 

    sReq.requestTag = FIND_FRIENDS_SDB; 

    [sdbClient select: sReq]; 

SELECT_STRINGFIND_FRIENDS_SDB是预定义的,有效的上下文字符串。

这是什么问题?谢谢!

更新:

得到委托工作。获取与我的SimpleDB SELECT查询相关的错误,显然我的SELECT表达式的语法无效。我得到两个错误,因为我做两个查询,这里的SELECT表达式为每个:

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

即看“类型”属性和“ITEMNAME()”,并检查他们是否等于东西该域名。

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')

这就是检查这些字符串是否出现在域的Email属性中。

注:

固定它,显然使用SELECT表达式时,域名不能有破折号。或破折号似乎以某种方式破坏请求

回答

5

当使用AmazonServiceRequestDelegate时,this blog post可能会有所帮助。基本上,您需要:

  1. 避免在后台线程中使用AmazonServiceRequestDelegate。
  2. 保留对客户的强烈参考。
  3. 保留强烈的参考代表。

此外,你应该确保你调用[AmazonErrorHandler shouldNotThrowExceptions],因为你没有实现request:didFailWithServiceException:。详情请看this blog post

+0

我将如何保留对**代表** AKA **自**的强烈参考? **请求:didFailWithServiceException:**已弃用BTW。 – MCKapur

+0

而且是的即时消息使用ARC – MCKapur

+0

有一个引用您的委托(在这种情况下'self')的对象必须确保委托在AWS操作完成之前不会被释放。我们故意弃用'request:didFailWithServiceException:',但是,您需要按照博客文章中的说明调用'[AmazonErrorHandler shouldNotThrowExceptions]'。否则,'request:didFailWithError:'不会被调用。 –

相关问题