在iOS版的Dropbox API:如何使用DBRestClient? [英] Dropbox API in iOS: How to use DBRestClient?

查看:146
本文介绍了在iOS版的Dropbox API:如何使用DBRestClient?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图遵循Dropbox的开发者网站上的说明,但我想不出如何正确添加DBRestClient对象。在@end后,我的.h文件中,现在我有:

I'm trying to follow the instructions on the Dropbox developer's site, but I can't figure out how to properly add a DBRestClient object. Right now in my .h file after @end I have:

DBRestClient *restClient;

在我的.m文件我有:

And in my .m file I have:

- (DBRestClient *)restClient {
    if (!restClient) {
        restClient =
        [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
        restClient.delegate = self;
    }
    return restClient;
}

这是Dropbox的页面告诉我这样做,我想;然而,这导致我​​的应用程序崩溃(我想是因为它试图当它不应该释放RESTClient实现)。我也试着列出RESTClient实现作为一个非原子属性,但随后上传等方法似乎并不工作。 (上传方法现在是工作的权利,一旦它完成上传...应用程序崩溃刚)帮助?

This is what the Dropbox page tells me to do, I think; however this results in my app crashing (I think because it tries to release restClient when it shouldn't). I've also tried listing restClient as a nonatomic property but then the uploading, etc methods don't seem to work. (The upload method IS working right now, the app just crashes once it's finished uploading...) Help?

推荐答案

Rupesh的基础上,于4月20日蜜蜂的评论的详细规范的答案是,已得到释放。

Rupesh, the detailed canonical answer based on bee's comment on Apr 20 is that self was getting deallocated.

这意味着一定有code这并依次执行以下操作。

this means there must have been code that did the following in order.


  1. 通过调用返回类型的对象(DBRestClient *)的 RESTClient实现函数创建一个变量

  2. 的变量设置它的成分(@property?可能)委托在功能(在看到
    上面的问题)

  3. 之后,对象指着被释放,这意味着代表并没有指向任何东西。

  4. 后依旧,一定有code,它试图取消引用委托某种目的。

  1. a variable created by calling the restClient function that returns an object of type (DBRestClient*)
  2. that variable sets it's component (@property? probably) delegate to self in that function (seen in the question above)
  3. later, the object self was pointing to was deallocated, meaning delegate was not pointing to anything.
  4. later still, there must have been code that was attempting to dereference delegate for some purpose.

千万记得将消息发送到零objc对象只有有效地导致没有发生或零转让,如果发送的消息是一个函数。因此崩溃一定是由于一些其他类型的取消引用。

do remember that sending messages to nil objc objects only effectively results in nothing happening or a zero assignment if the message being sent is a function. thus a crash must have been due to some other kind of dereference.

这篇关于在iOS版的Dropbox API:如何使用DBRestClient?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆