2016-10-02 34 views
1

對REST端點谷歌API的Objective-C的客戶端庫這是我第一次迅速和谷歌應用程序引擎的經驗。撥打國際長途的iOS斯威夫特項目

我創建了一個簡單的java後臺,做了一個發現文檔,使用服務生成器(新的REST服務生成器)來創建客戶端庫,添加了所有谷歌,specfic客戶端庫。

我不能在查詢中通過編譯器錯誤..

這裏是代碼:

let service: GTLRHelloworldService = GTLRHelloworldService() 
//no compiler problem with this line. 
//my GTLRHellowworldService is included through the bridging headers 
     service.isRetryEnabled = true 
     set myquery: GTLRHelloworldQuery_GreetingsEstablishHandShake = GTLRHelloworldQuery_GreetingsEstablishHandShake.query() 

     service.executeQuery(myquery) { (ticket:GTLRServiceTicket, resp:GTLRHelloworld_HelloGreeting, error: NSError) in 
        nameLabel.text = resp?.message 
       } 

的錯誤是在最後一行:

無法將類型的價值「 (GTLRServiceTicket,GTLRHelloworld_HelloGreeting,NSError) - >()'到期望的參數類型'GTLRServiceCompletionHandler?'

爲了您的信息GreetingsEstablishHandShake定義由servicegnerator創建的頭文件是:

/** 
* GTLRHelloworldQuery_GreetingsEstablishHandShake 
* 
* Method: helloworld.greetings.establishHandShake 
* 
* Authorization scope(s): 
* @c kGTLRAuthScopeHelloworldUserinfoEmail 
*/ 
@interface GTLRHelloworldQuery_GreetingsEstablishHandShake : GTLRHelloworldQuery 
// Previous library name was 
// +[GTLQueryHelloworld queryForGreetingsEstablishHandShake] 

/** 
* Fetches a @c GTLRHelloworld_HelloGreeting. 
* 
* @returns GTLRHelloworldQuery_GreetingsEstablishHandShake 
*/ 
+ (instancetype)query; 

@end 

,並在頭文件中的HelloGreeting對象是:

@interface GTLRHelloworld_HelloGreeting : GTLRObject 

@property(nonatomic, copy, nullable) NSString *message; 

@end 

回答

0

我翻譯的迅速代碼目標c。 我跟着 the very helpful google introduction for objective c for rest

我的代碼方向低於現在運行併成功地與服務器進行通信:

static GTLRHelloworldService *service = nil; 
if (!service) { 
    service = [[GTLRHelloworldService alloc] init]; 

    // Have the service object set tickets to retry temporary error conditions 
    // automatically 
    service.retryEnabled = YES; 

    //[GTMHTTPFetcher setLoggingEnabled:YES]; 
} 

GTLRHelloworldQuery_GreetingsEstablishHandShake * query = [GTLRHelloworldQuery_GreetingsEstablishHandShake query]; 

GTLRServiceTicket *ticket = [service executeQuery:query 
      completionHandler:^(GTLRServiceTicket *callbackTicket, 
           GTLRHelloworld_HelloGreeting *resp , 
           NSError *callbackError) { 
       _nameLabel.text = resp.message;}]; 

我將不勝感激,如果有人可以幫助我瞭解如何在迅速翻譯這個代碼,