在获取文档目录时索引0超出空数组的边界 [英] index 0 beyond bounds for empty array while getting to the documents directory

查看:159
本文介绍了在获取文档目录时索引0超出空数组的边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码进入文档目录。

I use the following code to get to the documents directory.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

为什么我的应用会因以下消息而崩溃?

Why would my app be crashing with the following message?

*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array

我看不出我的 NSArray (不可变数组)是如何为空的。该函数应该返回数组中的documents文件夹。有什么想法吗?

I can't see how my NSArray (immutable array) can be empty. The function is supposed to return the documents folder in an array. Any ideas?

推荐答案

1)你确定崩溃在那里吗?

1) Are you sure the crash is there?

2)并非完全相关,但可以帮助

2) Not totally related but can help.

这篇关于在获取文档目录时索引0超出空数组的边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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