NSMutableArray 上的 NSRangeException 异常

发布于 2024-12-14 23:00:11 字数 3101 浏览 3 评论 0原文

我收到以下错误请帮我解决。我的 Xcode 因以下错误而中止

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0140a5a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0155e313 objc_exception_throw + 44
    2   CoreFoundation                      0x014000a5 -[__NSArrayM objectAtIndex:] + 261
    3   UMMCelebrity                        0x00043903 -[UMMFlickrView photoGallery:urlForPhotoSize:atIndex:] + 115
    4   UMMCelebrity                        0x0004a9d6 -[FGalleryViewController createGalleryPhotoForIndex:] + 422
    5   UMMCelebrity                        0x0004a5ac -[FGalleryViewController loadThumbnailImageWithIndex:] + 172
    6   UMMCelebrity                        0x0004a189 -[FGalleryViewController preloadThumbnailImages] + 281
    7   UMMCelebrity                        0x00046f84 -[FGalleryViewController loadView] + 2132
    8   UIKit                               0x0029d00e -[UIViewController view] + 56
    9   UMMCelebrity                        0x00043050 -[UMMFlickrView pushphotoview] + 192
    10  UMMCelebrity                        0x000446c6 -[UMMFlickrView connection:didReceiveData:] + 2230
    11  Foundation                          0x00996835 _NSURLConnectionDidReceiveData + 159
    12  CFNetwork                           0x033bde72 _ZN19URLConnectionClient21_clientDidReceiveDataEPK8__CFDataPNS_26ClientConnectionEventQueueE + 262
    13  CFNetwork                           0x0348a6b3 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 247
    14  CFNetwork                           0x0348a9cf _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 1043
    15  CFNetwork                           0x033b5c80 _ZN19URLConnectionClient13processEventsEv + 100
    16  CFNetwork                           0x033b5acf _ZN17MultiplexerSource7performEv + 251
    17  CoreFoundation                      0x013eb8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    18  CoreFoundation                      0x0134988b __CFRunLoopDoSources0 + 571
    19  CoreFoundation                      0x01348d86 __CFRunLoopRun + 470
    20  CoreFoundation                      0x01348840 CFRunLoopRunSpecific + 208
    21  CoreFoundation                      0x01348761 CFRunLoopRunInMode + 97
    22  GraphicsServices                    0x018e21c4 GSEventRunModal + 217
    23  GraphicsServices                    0x018e2289 GSEventRun + 115
    24  UIKit                               0x001fbc93 UIApplicationMain + 1160
    25  UMMCelebrity                        0x00001d29 main + 121
    26  UMMCelebrity                        0x00001ca5 start + 53
)
terminate called after throwing an instance of 'NSException'

I am getting the following error please help me with a solution. My xcode gets aborted with the following error

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0140a5a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0155e313 objc_exception_throw + 44
    2   CoreFoundation                      0x014000a5 -[__NSArrayM objectAtIndex:] + 261
    3   UMMCelebrity                        0x00043903 -[UMMFlickrView photoGallery:urlForPhotoSize:atIndex:] + 115
    4   UMMCelebrity                        0x0004a9d6 -[FGalleryViewController createGalleryPhotoForIndex:] + 422
    5   UMMCelebrity                        0x0004a5ac -[FGalleryViewController loadThumbnailImageWithIndex:] + 172
    6   UMMCelebrity                        0x0004a189 -[FGalleryViewController preloadThumbnailImages] + 281
    7   UMMCelebrity                        0x00046f84 -[FGalleryViewController loadView] + 2132
    8   UIKit                               0x0029d00e -[UIViewController view] + 56
    9   UMMCelebrity                        0x00043050 -[UMMFlickrView pushphotoview] + 192
    10  UMMCelebrity                        0x000446c6 -[UMMFlickrView connection:didReceiveData:] + 2230
    11  Foundation                          0x00996835 _NSURLConnectionDidReceiveData + 159
    12  CFNetwork                           0x033bde72 _ZN19URLConnectionClient21_clientDidReceiveDataEPK8__CFDataPNS_26ClientConnectionEventQueueE + 262
    13  CFNetwork                           0x0348a6b3 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 247
    14  CFNetwork                           0x0348a9cf _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 1043
    15  CFNetwork                           0x033b5c80 _ZN19URLConnectionClient13processEventsEv + 100
    16  CFNetwork                           0x033b5acf _ZN17MultiplexerSource7performEv + 251
    17  CoreFoundation                      0x013eb8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    18  CoreFoundation                      0x0134988b __CFRunLoopDoSources0 + 571
    19  CoreFoundation                      0x01348d86 __CFRunLoopRun + 470
    20  CoreFoundation                      0x01348840 CFRunLoopRunSpecific + 208
    21  CoreFoundation                      0x01348761 CFRunLoopRunInMode + 97
    22  GraphicsServices                    0x018e21c4 GSEventRunModal + 217
    23  GraphicsServices                    0x018e2289 GSEventRun + 115
    24  UIKit                               0x001fbc93 UIApplicationMain + 1160
    25  UMMCelebrity                        0x00001d29 main + 121
    26  UMMCelebrity                        0x00001ca5 start + 53
)
terminate called after throwing an instance of 'NSException'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

半岛未凉 2024-12-21 23:00:11

您正在空 NSMutableArray 上使用参数 0 调用 objectAtIndex:

[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array

如果您知道 NSMutableArray 可以为空,则应考虑调用 count 来查看它是否确实包含任何元素,在尝试访问元素之前。

You're calling objectAtIndex: with the argument 0 on an empty NSMutableArray.

[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array

If you know the NSMutableArray can be empty, you should consider calling count on it to see if it does indeed contain any elements, before trying to access the elements.

隔岸观火 2024-12-21 23:00:11

显然,-[UMMFlickrView photoGallery:urlForPhotoSize:atIndex:] 中有一个空的 NSMutableArray,并且您使用参数 0 发送了 objectAtIndex:

Obviously, there's an empty NSMutableArray in -[UMMFlickrView photoGallery:urlForPhotoSize:atIndex:] and you sent it objectAtIndex: with argument 0.

仙气飘飘 2024-12-21 23:00:11

这意味着你的 NSMutableArray 是空的。我认为你没有为 NSMutableArray 分配内存。阅读此链接,它可能对您有帮助。
http://www.roseindia.net/answers /viewqa/Mobile-Applications/14614-NSMutableArray-Example-Code.html

That means your NSMutableArray is empty. I think you didn't allocate the memory for NSMutableArray. Read this link, it may be helpful for you.
http://www.roseindia.net/answers/viewqa/Mobile-Applications/14614-NSMutableArray-Example-Code.html

蹲墙角沉默 2024-12-21 23:00:11

可能在第四次单击时,没有任何内容被推入数组中,我不确定,因为我不知道您要做什么。如果您可以添加将对象添加到数组中的代码行,我们可以帮助您。

发生此错误是因为数组肯定是空的。

May be on the 4th click nothing is pushed into the array, I'm not sure as I have no idea what you are trying to do.If you can add the code line that adds the object into your array, we could help you.

This error is occurring because the array is empty for sure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文