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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:53:39+00:00 2026-05-24T00:53:39+00:00

Noob here getting stuck and probably doing something stupid and would appreciate some guidance.

  • 0

Noob here getting stuck and probably doing something stupid and would appreciate some guidance.

I’ve declared an NSMutableArray (resultArray) in my .h file, set the @property and @synthesize in the .m file.

In the initWithNibName i’m doing the alloc and init for the array:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
        resultArray = [[NSMutableArray alloc] init];
    }
    return self;
}

And in one of my methods i’m trying to do an addObject within a for loop, but whatever i try the array does not appear to contain objects (either by using objectAtIndex or count):

for (int i=[resultNumber length]; i>0; i--) {   
    NSString *theNumberRes = [NSString stringWithFormat:@"%c",[resultNumber characterAtIndex:i-1]]; 
    [resultArray addObject:theNumberRes];
}

NSLog(@"array count: %i", [resultArray count]);

I can step through the code and see the code running through the loop as many times as expected, but the NSLog never gives a result other than 0 (and hovering over the resultArray shows 0 objects at all times. (In brief, each object in the array is supposed to be a character from a string in reverse – e.g. if resultNumber is 12345, the array should store 5,4,3,2,1).

I have seen a number of other questions asking similar questions but they either don’t seem to help or i don’t understand the answer and didn’t want to hijack someone else’s question with my question.

Please could someone advise me as to how to get this working?

  • 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-24T00:53:40+00:00Added an answer on May 24, 2026 at 12:53 am

    The question is if the - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil method get called. There is other initialization routines such as

    -(id)init; 
    -(id)initWithCoder:(NSCoder)aDecoder;
    

    If your view is loading from a .xib file there is a possibility, that the last one is called and not the one you are initializing your array in.

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

Sidebar

Related Questions

Rails 3 noob here. Currently the code in my controller below is getting the
I have a noob question here. I'm getting my head around the C++ structure
Rails noob here so I'm not sure what I'm doing wrong. We're replacing a
Complete noob to C , just getting started with some goofing around, wondering how
Hey everbody, im getting some trouble here. When my viewcontroller reaches the view, it
I've hit a wall and need some guidance getting this to work. I preface
noob here still experimenting with templates. Trying to write a message processing class template
NOOb here. I've got a HTTP request that pulls all of the content from
Total noob here with javascript. I'm trying to alter a function. This is the
Total noob here. This is my first c# attempt, its a console application that

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.