2013-01-17 112 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:'不會被調用。 –

相關問題