问题标签 [nsrangeexception]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
105 浏览

ios - Accessing database using sections in UICollection

I am developing small application in iOS (I am complete beginner). I have made a menu Core Data entity where I have categoryName and imageNamed saved. I want my UICollectionView in sections. But I am stuck in defining different indexPaths for different sections.

I also feel that my way of accessing data is very poor and seems inefficient as I am defining two NSFetchedResultsController instances. How can I access the data store better?

I get this error:

14-03-17 10:02:19.974 citiliving[1149:70b] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'

Error seems is out of bound so section is accessing something that is not in array boundaries.

Code to access data in viewDidLoad:

Note: I wanted to create object in variable which I can easily access in further code but I tried all variable could not do it.

Code used to get sections:

Finally getting everything in indexPath (here I am getting error as soon as I put 2nd section coding otherwise first section running ok:

I have only two sections and one has 5 rows and other have 6 rows. I wanted to make this one controller to access data and put everything in variables so later I can use variables. My database is categoryName | categoryImage | section

where section identify section one and two so I use predicate to make two different section using section field value.

0 投票
2 回答
1042 浏览

ios - UITableView bounds Terminating app 'NSRangeException' -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'

遇到以下代码问题:我有这个 LeavemanagementViewController.m

我正在从服务器的 xml 中提取和加载数据。元素的总数取决于数组。

请帮我解决这个问题。

0 投票
3 回答
198 浏览

ios - 表格单元格展开时应用程序崩溃

当按下已经存在的单元格时,我有一个系统可以将一个单元格添加到一个部分。当我尝试在 indexpath 3 之后(包括 indexpath 3)展开任何部分时,应用程序崩溃。它会生成以下崩溃报告:

通过查看崩溃报告,我认为这种方法被破坏了:

0 投票
3 回答
581 浏览

ios - iOS 核心数据 NSRangeException

我有一个我无法解决的问题。我正在使用 Core Data 框架创建一个 iOS 应用程序。在我得到 NSRangeException 之前,一切都很顺利。这个异常是我在检查应用程序数据是否需要更新的函数中得到的。

我的代码是:

例外:

伙计们,有人可以帮帮我吗?我真的需要你的帮助。谢谢你。

0 投票
1 回答
197 浏览

objective-c - 具有不同长度数组的一个视图控制器中的 Objc 2 个集合视图

我正在我的应用程序中创建一个页面,其中分段控件显示两个不同的集合视图。CV 的数据来自包含两个不同长度数组的 API。

我的问题是第一个集合视图在数组中的项目比第二个多,第二个集合视图在 cellAtIndexPath 中的迭代次数超过了所需的次数,因此返回错误*由于未捕获的异常“NSRangeException”而终止应用程序,原因:'- [__NSCFArray objectAtIndex:]: 索引 (1) 越界 (1)'

任何人都可以帮助我吗?

谢谢

0 投票
1 回答
184 浏览

ios - NSRange 在 for 循环中改变自身

我有一个 NSRange 对象的 NSDictionary,它们在数组中的索引键。我正在尝试使用这些范围中的每一个来创建更大字符串的子字符串,并将这些子字符串中的每一个放入数组中。我基本上已经完成了,但是 NSRange 神秘地改变了它在代码中的值,导致它崩溃并抛出异常。这是我的代码:

我的日志输出如下所示:

0 投票
3 回答
2679 浏览

ios - substringWithRange 越界——我错过了什么?

我试图从一些代码中提取一些字符串,但我遇到了一个NSRangeException我不明白的问题。这是我的代码:

adlerNumber已创建并记录没有错误。但是随后尝试创建translatedHeadword(上面的最后一行代码)给了我这个错误:

如果targetRangeHeadword.length记录为 27 并targetRangeHeadword.location记录为 2496,我怎样才能得到NSRangeException给我的数字?我该如何解决这个问题?

提前感谢您的帮助,伙计们和女孩们。

0 投票
0 回答
137 浏览

ios - xcode项目导出错误

我有这个问题:我将我的 xcode 项目发送给朋友,他能够毫无错误地打开和运行,但在某些时候应用程序崩溃了。更准确地说,app 管理一个存储游戏分数的 sqlite 数据库,当他尝试进入显示分数的页面时,应用程序崩溃,NSRangeException因为存储从数据库中提取的分数的数据结构是空的。

当然,在我的 Xcode 中它工作得很好,在导出项目以使其在另一台 Mac 上工作之前我需要做些什么特别的事情吗?我是否还应该添加 db 文件并让他重新导入到他的项目中?我刚刚使用项目文件夹创建了一个 zip 文件。如果有人可以帮助我,将不胜感激。谢谢

0 投票
1 回答
1421 浏览

objective-c - 使用范围创建子数组时抛出 NSRangeException

这是我得到的一个非常奇怪的错误。是这样的:

我不明白的是范围(2,3)显然没有超出范围(0,3)的范围

事实上,它在这些范围内,因为我像这样设置数组和范围:

本质上,我正在遍历一个名为 wordArray 的数组,并且我想创建一个子数组,其中包含我尚未遍历的所有项目。有谁可以帮我离开这里吗?

0 投票
1 回答
154 浏览

objective-c - NSRangeException indexSet 计数或 lastIndex 不得超过 -numberOfAssets

我有一个来自我们团队的老成员的新项目。不知道问题出在哪里...

2014-09-04 11:37:55.960 IMDropShare [28350:60b] 警告:GoogleAnalytics 3.06 void GAIuncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:49):未捕获的异常:indexSet 计数或 lastIndex 不得超过 -numberOfAssets 2014-09- 04 11:38:00.980 IMDropShare [28350:60b] *由于未捕获的异常“NSRangeException”而终止应用程序,原因:“indexSet 计数或 lastIndex 不得超过 -numberOfAssets”