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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:31:34+00:00 2026-05-25T09:31:34+00:00

Ideally, I would like to make a function add objects in a NSMutableArray, and

  • 0

Ideally, I would like to make a function add objects in a NSMutableArray, and then do whatever I want with this array in another function.

Here is what I’ve tried to do lately, of course it doesn’t work but it gives you an idea of what I want to do:

- (void)someThing 
{  
   (...)

NSMutableArray *arrayOfThings = [[NSMutableArray alloc] init];

while (theObject = [aNSEnumerator nextObject]) {
   const char *theObject_fixed = [theObject UTF8String]; 

   function_something(theObject_fixed);
}

// do something with arrayOfThings


}



void function_something(const char *file)
{

    (...)


unsigned int *p = memmem(buffer, fileLen, bytes, 4);

NSMutableString *aString = [[NSMutableString alloc] initWithCapacity:48];

unsigned long off_to_string = 0x10 + 4 + ((void *)p) - ((void *)buffer);

for (unsigned long c = off_to_string; c<off_to_string+0x30; c++)
{

[aString appendFormat:@"%.2x", (int)buffer[c]];

}

 NSLog(@"%s: %@", file, aString);   

[arrayOfThings addObject:[aString copy]];

 free(buffer);
  • 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-25T09:31:34+00:00Added an answer on May 25, 2026 at 9:31 am

    There are two ways to go about this:

    The first requires only a slight modification to your code will allow you to do what you want:
    In the funciton someThing pass the mutable array as an additional parameter.

    function_something(theObject_fixed, arrayOfThings);
    

    Then change function_something to accept that parameter.

    void function_something(const char *file, NSMutableArray *arrayOfThings) {
        // Code remains the same
    }
    

    The other and in my opinion better solution would be for the function_something to return the fixed string as an NSString object and let someThing do the adding to the mutable array.
    So we get something like this in someThing:

    ...
    NSString *aString = function_something(theObject_fixed);
    [arrayOfThings addObject:aString];
    

    And then a redefined *function_something*:

    NSString* function_something(const char *file) {
        ...
        return [aString autorelease];
    }
    

    By the way, your code is leaking memory. Be careful with you retain/release/autorelease.

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

Sidebar

Related Questions

I would like to get a list of the wireless networks available. Ideally this
What I would like is a handy GUI to inspect objects. The dir() function
This obviously requires the source file to be under source control. I would ideally
I am trying to link a twitter account to wordpress. Ideally I would like
I would like to log function calls made during the execution of a C
Is there a function out there to make sure that any given array conforms
I'm on the lookout for tools to migrate from ClearCase to SVN. Ideally would
I have two HTML tables which would ideally be placed side by side on
Anyone know of a good free winforms html editor for .NET. Ideally I would
What is the best way to approximate a cubic Bezier curve? Ideally I would

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.