【问题标题】:How to convert objective-c snippet to Rubymotion如何将objective-c片段转换为Rubymotion
【发布时间】:2016-02-10 08:36:11
【问题描述】:

我正在使用 Rubymotion 构建一个 iOS 应用程序。我需要将这个 Objective C 代码“转换”成 ruby​​。应该怎么看。我被卡住了。

ASRemoteIndex *index = [apiClient getIndex:@"YourIndexName"];
[index search:[ASQuery queryWithFullTextQuery:@"jim"]
  success:^(ASRemoteIndex *index, ASQuery *query, NSDictionary *answer) {

} failure:nil];

// setting some query parameters
ASQuery* query = [ASQuery queryWithFullTextQuery:@"jim"];
query.hitsPerPage = 5;
[index search:query success:^(ASRemoteIndex *index, ASQuery *query, NSDictionary *answer) {

} failure:nil];

【问题讨论】:

  • 尝试一些在线转换器,比如this,可能会有所帮助。
  • 我试过了,但没有帮助

标签: objective-c rubymotion


【解决方案1】:

像这样:

index.search(ASQuery.queryWithFullTextQuery("jim"), success:lambda do |index, query, answer|
       # optional block code here
    end, failure:nil)

query = ASQuery.queryWithFullTextQuery("jim")
index.search(query, success:lambda do |index, query, answer|
       # optional block code here
    end, failure:nil)

在这里阅读:RubyMotion Runtime Guide: Function Pointers and Blocks

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-14
    • 2014-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多