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

查看:27
本文介绍了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,基于 bee 在 4 月 20 日评论的详细规范答案是 self 正在被释放.

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

这意味着一定有代码按顺序执行了以下操作.

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

  1. 通过调用 restClient 函数创建的变量,该函数返回类型为 (DBRestClient*) 的对象
  2. 该变量将它的组件(@property?可能)delegate 设置为该函数中的 self(见上面的问题)
  3. 后来,self 指向的对象被释放,这意味着委托没有指向任何东西.
  4. 再后来,一定有代码为了某种目的试图取消对委托的引用.
  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.

请记住,如果发送的消息是一个函数,则向 nil 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天全站免登陆