Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6857827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:04:45+00:00 2026-05-27T02:04:45+00:00

I have a nethod to refresh the content of a UIScrollView. Within the ScrollView

  • 0

I have a nethod to refresh the content of a UIScrollView. Within the ScrollView there are several UIImageViews and some UILabels.

I do clean the content of the scrollView with the following code:

for (int i = [publicationsScrollView.subviews count] -1; i>=0; i--) {
    NSLog(@"Deleting SubView: %@", [[publicationsScrollView.subviews objectAtIndex:i] class]);
    if ([[publicationsScrollView.subviews objectAtIndex:i] isKindOfClass:[UIButton class]] || [[publicationsScrollView.subviews objectAtIndex:i] isKindOfClass:[UIButtonLongTap class]] || [[publicationsScrollView.subviews objectAtIndex:i] isKindOfClass:[UILabel class]] || [[publicationsScrollView.subviews objectAtIndex:i] isKindOfClass:[UIImageView class]]) {
        NSLog(@"Deleting SubView: %@", [[publicationsScrollView.subviews objectAtIndex:i] class]);
        [[publicationsScrollView.subviews objectAtIndex:i] removeFromSuperview];
    }
    if ([[publicationsScrollView.subviews objectAtIndex:i] isKindOfClass:[iCarousel class]]) {
        NSLog(@"carousel: View is in Scrollview");
    }
}

This code ran fine for some days. Now i recieve an error during refresh in console:

refreshWorkSpace: deleting all subviews (11)
2011-11-25 14:04:52.826 CatalogService[45054:fb03] Deleting SubView: UILabel
2011-11-25 14:04:52.827 CatalogService[45054:fb03] Deleting SubView: UILabel
2011-11-25 14:04:52.839 CatalogService[45054:fb03] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 10 beyond bounds [0 .. 9]'
*** First throw call stack:
(0x1e8c052 0x231fd0a 0x1e78db8 0x6945 0x5826 0x1e8dec9 0xddc5c2 0xddc55a 0xe81b76 0xe8203f 0xe81bab 0xecfa99 0xed1407 0xe0193f 0xe01c56 0xde8384 0xddbaa9 0x28b6fa9 0x1e601c5 0x1dc5022 0x1dc390a 0x1dc2db4 0x1dc2ccb 0x28b5879 0x28b593e 0xdd9a9b 0x2e6d 0x2de5 0x1

I can not understand what’s happening here. I loop through the subviews (count should give me the number of existing subviews !?). Why could the Index be out of Bounds !?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:04:46+00:00Added an answer on May 27, 2026 at 2:04 am

    I would suspect the exception is being thrown on this line:

    if ([[publicationsScrollView.subviews objectAtIndex:i] isKindOfClass:[iCarousel class]]) {
    

    in the case where [[publicationsScrollView.subviews objectAtIndex:i] removeFromSuperview] has just executed there will no longer be an object at index ‘i’. This would only happen if the last subview in the array was one of the types you delete – otherwise the access would be harmless.

    To fix, you could just add a continue after the removeFromSuperview call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =
Have added the following code to my SQL query: (Note cut down version) DECLARE
Have some code: using (var ctx = new testDataContext()) { var options = new
Have a look at the following code to find X^y. /* Find exponent in
Have the following code. The height is variable so the height of the floating
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have you managed to get Aptana Studio debugging to work? I tried following this,
Have been following Rails Tutorial by Michael Hart rails version 3.0 on mac OS
Have written all the code in a silverlight class library (dll) and linked this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.