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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:12:28+00:00 2026-05-19T04:12:28+00:00

I’m working on an iPhone app using objective C. I’ve got class A, which

  • 0

I’m working on an iPhone app using objective C. I’ve got class A, which creates an NSMutableArray pointer called “list”. But, in class A, I never create an object for it to point to. Instead, I call a class method in class B, to get some data from an sqlite database, and populate an NSMutableArray object there. I want to be able to set the pointer in class A to point to the NSMutableArray object created in the class B method by passing it as an argument to the method. I can’t do it by returning the array because I want to return the sqlite result.

I wonder if I’m doing this right? I haven’t written the entire method yet (when it’s done it’ll be pretty long), but I want to know if I’m doing the pointer stuff correctly before I get started on the rest.

//ClassA.m

//...
NSMutableArray *list;
[ClassB populateArrayFromSqlite:&list];
//Now do stuff with "list", which should point to the array created in populateArrayFromSqlite
//...

//ClassB.m
+(int)populateArrayFromSqlite:(NSMutableArray**)ar {
    NSMutableArray *array = [[NSMutableArray alloc] init];
    //Here there will be code that populates the array using sqlite (once I write it)
    //And then I need to set the "list" pointer in ClassA.m to point to this array
    ar = &array; //Is this how?

    return resultFromSqlite;
}

Did I do it right? Or am I not understanding something? I guess this pointer-to-pointer stuff just doesn’t click with me yet. After reading a few general sources about pointers, I suspect this is how I’d do it but part of me doesn’t understand why the ar argument can’t just be a regular pointer (as opposed to a pointer-to-pointer).

  • 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-19T04:12:29+00:00Added an answer on May 19, 2026 at 4:12 am

    Pointers to pointers are a bit escheric, yes. The simple way to do it would be to create an empty array in A and pass a regular array pointer to B that would just fill it. If you insisted on creating the array in B, I think you could do this:

    - (void) createArray: (NSMutableArray**) newArray
    {
        NSAssert(newArray, @"I need a pointer, sweetheart.");
        *newArray = [[NSMutableArray alloc] init];
        [*newArray addObject:...];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of 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.