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 8643301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:00:05+00:00 2026-06-12T12:00:05+00:00

Ok so I;m building an interface to allow admins controlls over certain rules which

  • 0

Ok so I;m building an interface to allow admins controlls over certain rules which are controlled using UISwitches (a lot of them)

so I’ve declared an array of switches

NSMutableArray *cameraSwitches = [[NSMutableArray alloc] initWithObjects:
loc0CamProfileSwitch, loc1CamProfileSwitch, loc2CamProfileSwitch,
loc3CamProfileSwitch, loc4CamProfileSwitch, loc5CamProfileSwitch,
loc6CamProfileSwitch, loc7CamProfileSwitch, loc8CamProfileSwitch, nil]; 

where each object inside the Array is a UISwitch,

and then I’m looping through a diff array checking for initial values of these switches

for (NSUInteger i = 0; i < [camP count]; i++) {

    if ([camP objectAtIndex:i] != 0) {

        //UISwitch *csw = [cameraSwitches objectAtIndex:i];
        //[csw setOn:YES];

        [[cameraSwitches objectAtIndex:i] setOn:YES];
    else { [loc7CamProfileSwitch setOn:NO]; }
}

But everything I’m trying is giving me an error at runtime, throwing an exception
'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'

using break points: I realize theres something wrong with this line

[[cameraSwitches objectAtIndex:i] setOn:YES]; – or with how i initiated the array any help is very very appreciated

  • 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-06-12T12:00:07+00:00Added an answer on June 12, 2026 at 12:00 pm

    cameraSwitches is correctly instantiated. that’s why you get an exception raised when you try to reach index 0.

    But, did you checked that loc0CamProfileSwitch (index 0) is non nil?

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

Sidebar

Related Questions

Using c# 4.0 -- building an interface and a class that implements the interface.
I'm building a game of which the interface is one of the first items
I'm building an interface layer for a Matlab component which is used to analyse
I'm working on building my own base user interface classes. On them, I want
I'm building the interface within interface builder and see that there's a variety of
I am building a WCF service interface for an existing Windows service process. The
Hi all im building a web user interface. In this interface i use popup
I am working on building a HTML5 video player with a custom interface, but
I’m building a custom robotish machine that has 8 switches I need to interface
I'm building a Dojo DataGrid from JSON data provided by my REST interface. The

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.