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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:14:28+00:00 2026-06-13T23:14:28+00:00

I am puzzled by some behaviour I’m seeing in Objective-C. I have a method

  • 0

I am puzzled by some behaviour I’m seeing in Objective-C.

I have a method as follows:

-(void)showFormWithId:(NSString*)formId andMode:(int)mode
{
    HPSModelForm* model = [HPSDbUtilities getForm:formId];
    HPSFormController* formVC = [ [ HPSFormController alloc ] init ];
    [(UINavigationController*) self.view.window.rootViewController pushViewController:formVC animated:YES];


}

Within the HPSFormController class my implementation contains the following:

@implementation HPSFormController
NSArray* _arrayOfPageNosWithSummaryElements;

i.e. _arrayOfPageNosWithSummaryElements is not a property, but is an ivar visible to any method within the HPSFormController class. It is not declared in the header file at all.

When I call showFormWithId the first time then _arrayOfPageNosWithSummaryElements is nil. However, when I call showFormWithId a second time then it seems to me that _arrayOfPageNosWithSummaryElements is not nil, but has the value from the previous instance of HPSFormController. I don’t understand this – surely because the scope of the formVC is the showFormWithId method then the second time I call showFormWithId then a completely new instance of HPSFormController should be created with _arrayOfPageNosWithSummaryElements uninitialised and therefore set to nil?

What am I doing wrong? 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-13T23:14:29+00:00Added an answer on June 13, 2026 at 11:14 pm
    @implementation HPSFormController
    NSArray* _arrayOfPageNosWithSummaryElements;
    

    is no ivar declaration but a declaration of a global variable. You have to use brackets:

    @implementation HPSFormController {
       NSArray* _arrayOfPageNosWithSummaryElements;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some question which puzzled me for a long time. What is the
I have been really puzzled because I was trying to work out some jQuery
I am learning some COM code and the following code puzzled me. STDMETHODIMP _(ULONG)
I've been reading on this quite some time...and i'm puzzled - Can you help
I have some weird problem in rendering some xhtml in IE 8 http://img709.imageshack.us/i/scrj.png/ .
for some reason this hasn't been inserting into the database. I'm puzzled. It runs
I have been toying with some codes to solve this using a Levenberg-Marquardt solver
I was very puzzled by some unexpected compile errors in my code recently. I
I'm looking at some sample code and I'm puzzled over the lack of declaration
I am new to R and am puzzled by this problem when manipulating some

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.