【问题标题】:Backendless - How To Get Objects From 'Data'Backendless - 如何从“数据”中获取对象
【发布时间】:2016-02-09 10:13:45
【问题描述】:

如何将 Backendless 数据库中的所有对象放入 iOS 应用中的 UITableView?

查看他们的文档,它没有明确说明如何获取所有对象。 (我是平台新手)

任何帮助将不胜感激!

【问题讨论】:

  • 真的没有让你明白。能否请您提供更多详细信息?.. 像后面无尽的数据库是您的网络数据库还是云数据库或本地数据库?
  • 是云数据库

标签: ios objective-c xcode backendless


【解决方案1】:

这是我在 Swift 中的操作方式(对于我的 Blurb 对象表):

  func retrieveBlurbs() {
    let query = BackendlessDataQuery()
    // Use backendless.persistenceService to obtain a ref to a data store for the class
    let dataStore = self.backendless.persistenceService.of(Blurb.ofClass()) as IDataStore
    dataStore.find(query, response: { (retrievedCollection) -> Void in
      print("Successfully retrieved: \(retrievedCollection)")
      self.blurbs = retrievedCollection.data as! [Blurb]
      self.tableView.reloadData()
      }) { (fault) -> Void in
        print("Server reported an error: \(fault)")
    }
  }

我也是 Backendless 的新手,非常喜欢它!它很像 Parse,但在很多方面都更好。

【讨论】:

  • 这就是我转向 Backendless 的原因,因为它具有与 Parse 相似的功能,因为它在 2017 年退休的不幸消息。你有机会知道这在 Objective-C 中是什么吗?跨度>
  • 您可以找到许多我在 Objective-c here in their documentation 中调用的相同方法,我建议查看我所做的事情,然后在这些文档中显示的示例中找到与 Objective-c 等效的方法。
【解决方案2】:
【解决方案3】:

试试这个:

- (void)viewDidLoad {
   [super viewDidLoad];
   [self getDataFromBackendless];
}

-(void)getDataFromBackendless {
    @try {
        BackendlessCollection *documents = [backendless.persistenceService of:[YOUR_TABLE_NAME class]];
        currentPage =[documents getCurrentPage];
    }
    @catch (Fault *fault) {
        NSLog(@"Server reported an error: %@", fault);
    }
}

然后执行 UITableView 方法:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      return [currentPage count];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-09
    • 2017-01-04
    • 1970-01-01
    • 2013-08-21
    • 2011-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多