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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:00:34+00:00 2026-06-02T01:00:34+00:00

I am trying to use the addObjectsFromArray to concatenate (so to speak) two arrays

  • 0

I am trying to use the addObjectsFromArray to “concatenate” (so to speak) two arrays together. Here is an overview of the code:

NSArray *fixed = [NSArray arrayWithArray:timeline2];
NSLog(@"Made the temp successfully.Contents: %@", fixed);

[arrayOfNewsItems addObjectsFromArray:fixed];

The Log statement can confirm that there is valid data in the “fixed” and “timeline2” arrays, and earlier in the program, I confirmed that data exists in the “arrayOfNewsItems” array.

The exception I receive after the attempt at addObjects.. is this:

'NSInternalInconsistencyException', reason: '-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'

arrayOfNewsItems is a NSMutableArray. It’s a property. Actually, it’s declared like this:

@property (nonatomic) NSMutableArray * arrayOfNewsItems;

Perhaps it’s the “nonatomic” statement? I don’t fully understand these either.

The only thing I can think of is that the array elements in each array have different object types – or rather, although they are each arrays of dictionary objects, the objects themselves consist of a different list of key/value pairs. For example:

Array element 1 might contain:

(key)                 (value)
name                   Joe
title                  Mr.

And Array element 2 might contain:

(key)                 (value)
phone                 555-1263
shoeSize              2

Now, in any other language, I would never try this, but I’m pretty sure I was told in an earlier post that this was OK to do. I understand that objective-c stores them as (id), and we can mash everything in there together like that. So, the questions are:

  • Is this true?
  • If so, what have I missed?

I would to get a solid answer on this, before I start coding a function to make all field names the same for the final array.

I would certainly appreciate any and all help I can get! Thanks.

  • 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-02T01:00:36+00:00Added an answer on June 2, 2026 at 1:00 am

    Well, it’s pretty clear: mutating method sent to immutable object
    This means that you have an immutable instance of NSArray.

    Even though it is defined as NSMutableArray, it doesn’t mean that it really is one. It only removes the warnings when trying to call mutating methods like -addObjectsFromArray:.

    You have to make sure that when creating the array, you send alloc/init to the mutable version:

    self.arrayOfNewsItems = [[[NSMutableArray alloc] init] autorelease];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm a little confused here, I am trying use a partial view in a
I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char
I am trying use std::copy to copy from two different iterator. But during course
I'm trying use regular expression to convert special characters in an url. Here's my
I was trying use the code shown below to plot in such a way
I am trying use an if statement and TWO .addClass background-color variables based on
I am trying use Google Maps for my work; I have downloaded an example
I am trying use this example http://www.sajithmr.me/jrecorder/example2.html for recording audio and send it to
I was trying use a set of filter functions to run the appropriate routine,

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.