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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:01:08+00:00 2026-06-15T18:01:08+00:00

Ok, so I am working with two sets of data that are extremely similar,

  • 0

Ok, so I am working with two sets of data that are extremely similar, and at the same time, these data sets are both global NSMutableArrays within the object.

data_set_one = [[NSMutableArray alloc] init];
data_set_two = [[NSMutableArray alloc] init];

Two new NSMutableArrays are loaded, which need to be added to the old, existing data. These Arrays are also global.

xml_dataset_one = [[NSMutableArray alloc] init];
xml_dataset_two = [[NSMutableArray alloc] init];

To reduce code duplication (and because these data sets are so similar) I wrote a void method within the class to handle the data combination process for both Arrays:

-(void)constructData:(NSMutableArray *)data fromDownloadArray:(NSMutableArray *)down withMatchSelector:(NSString *)sel_str

Now, I have a decent understanding of object oriented programming, so I was thinking that if I were to invoke the method with the global Arrays in the data like so…

[self constructData:data_set_one fromDownloadArray:xml_dataset_one withMatchSelector:@"id"];

Then the global NSMutableArrays (data_set_one) would reflect the changes that happen to “array” within the method. Sadly, this is not the case, data_set_one doesn’t reflect the changes (ex: new objects within the Array) outside of the method.

Here is a code snippet of the problem

// data_set_one is empty
// xml_dataset_one has a few objects

[constructData:(NSMutableArray *)data_set_one fromDownloadArray:(NSMutableArray *)xml_dataset_one withMatchSelector:(NSString *)@"id"];

// data_set_one should now be xml_dataset_one, but when echoed to screen, it appears to remain empty

And here is the gist of the code for the method, any help is appreciated.

-(void)constructData:(NSMutableArray *)data fromDownloadArray:(NSMutableArray *)down withMatchSelector:(NSString *)sel_str {
    if ([data count] == 0) {
        data = down;  // set data equal to downloaded data
    } else if ([down count] == 0) {
        // download yields no results, do nothing
    } else { 
        // combine the two arrays here 
    }
}

This project is not ARC enabled.

Thanks for the help guys!
Rob

  • 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-15T18:01:10+00:00Added an answer on June 15, 2026 at 6:01 pm

    If I understood your problem, you are trying to pass your object as call-by-reference and hoping to work as in C++/C. But Obj-C, although similar but has some different way. You have to dereference the object by using ** (double pointer) as mostly seen in NSError case, which is very rare.

    Second ways is: wrap method as a block. Then put the variable in the same lexical scope as the block, and denote it by __block storage type.

    Third way can be accessing your object directly by making it an ivar/property or even an singleton.

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

Sidebar

Related Questions

I am working on an application that needs to match two sets of data
I'm trying to plot two sets of data wrt to time on the same
After working with different data sets in SAS for a month or two, it
I am working on a filter functionality using ajax/jquery and php/mysql.I have two sets
I'm working with two-dimensional array-values that should be inserted into a ArrayList. But this
I am implementing many SSB working on two different instances. They are data push
In our application, we have two sets of tables: One set of working tables
I need to write a stored procedure that will provide the data from two
I have two sets of data which I need to join, but there is
Matlab Dates mismatch between two sets of data. Help! Please forgive the simplicity of

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.