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

  • Home
  • SEARCH
  • 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 7741823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:07:39+00:00 2026-06-01T09:07:39+00:00

I declared a NSArray object in .h file as @property (nonatomic, assign) NSArray *scnArray;

  • 0

I declared a NSArray object in .h file as

@property (nonatomic, assign) NSArray  *scnArray;

and in .h file under - (void)viewDidLoad I created three different NSArray objects as

NSArray  *obj1 = [[NSArray alloc] initWithObjects:@"1",@"0",@"0",nil];
NSArray  *obj2 = [[NSArray alloc] initWithObjects:@"0",@"3",@"0",nil];
NSArray  *obj3 = [[NSArray alloc] initWithObjects:@"0",@"0",@"5",nil];

scnArray = [[NSArray alloc] initWithArray:obj1];
[scnArray arrayByAddingObjectsFromArray:obj2];
[scnArray arrayByAddingObjectsFromArray:obj3];

and if I access this scnArray from any other function

NSArray *caseArray = [scnArray objectAtIndex:index];//index will be 0, 1, 2…

I am getting BAD_ACCESS_ERROR. What is the problem here and how can I correct to use it?

  • 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-01T09:07:40+00:00Added an answer on June 1, 2026 at 9:07 am

    Try this :

    NSArray  *obj1 = [[NSArray alloc] initWithObjects:@"1",@"0",@"0",nil];
    NSArray  *obj2 = [[NSArray alloc] initWithObjects:@"0",@"3",@"0",nil];
    NSArray  *obj3 = [[NSArray alloc] initWithObjects:@"0",@"0",@"5",nil];
    
    scnArray = [[NSArray alloc] initWithArray:obj1];
    scnArray = [scnArray arrayByAddingObjectsFromArray:obj2];
    scnArray = [scnArray arrayByAddingObjectsFromArray:obj3];
    

    The arrayByAddingObjectsFromArray: function adds all objects from array B to array A, and return the result (=the array containing both A’s and B’s elements).

    So, you should simply GET that result… 🙂

    IMPORTANT : scnArray MUST be an NSMutableArray array, and NOT an NSArray (it’s changing, right?); so make sure you edit that part too…

    ALSO : NSArray *caseArray = [scnArray objectAtIndex:index]; – this doesn’t make any sense. Setting an array to an ELEMENT of the scnArray? It doesn’t contain arrays, right? It just contains ELEMENTS of those arrays (the ones we’ve added)…

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

Sidebar

Related Questions

So assume I declared an object and created a retained property for it which
I declared a delegate: public delegate void Del(string message); Then i created a function
I have declared a property in the header file, for example @interface myClass {
I declared NSArray in my class NSArray *labelsArray; I made it a property @property
I have three variable declared as doubles: double Delay1 = 0; double Delay2 =
When I tried to check the size of NSArray which is declared without any
I learned something new while trying to figure out why my readwrite property declared
Initially i declared a 2D array in this way: subUrb = [[NSArray alloc] initWithObjects:
I have a block of code that adds an object to an array declared
I would like to observe the count property of an NSMutableArray object. I was

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.