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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:26:06+00:00 2026-05-12T21:26:06+00:00

Iam a newbiew to iPhone development. Version of my SDK is 2.2 In my

  • 0

Iam a newbiew to iPhone development. Version of my SDK is 2.2

In my code, UIViewController is used to change view dynamically once the app is launched, a method in the UIViewController is called to know which view should be initialized along with parameters, which goes to a ‘switch-case’ and assign a view to current view according to the parameter, like this:

    case 1:
        currentView = [[View01 alloc] init];
        break;
    case 2:
        currentView = [[View02 alloc] init];
        break;

and outside the switch-case:

[self.view addSubview:currentView.view];

I wonder f can pass a parameter along with initialization, like iniWithNibName or so? I need this because have to manipulate in the leaded view, according to the view from which its called.

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-05-12T21:26:06+00:00Added an answer on May 12, 2026 at 9:26 pm

    One way to approach this is to modify your View01 and View02 classes to include an initWithParam: initialiser.

    i.e. add

    - (id) initWithParam:(NSString *)myParam;
    

    to the @interface section and add

    - (id) initWithParam:(NSString *)myParam {
      if (self = [self init]) {
        // handle or store 'myParam' somewhere for use later
      }
    
      return self;
    }
    

    to the @implementation section. Notice how the initWithParam: message internally calls the existing init. Obviously you could change the type, or number of parameters passed in as required.

    Another approach would be to provide a property on your view class, so you could do something like the following:

    currentView = [[View01 alloc] init];
    currentView.myParam = @"SomeValue";
    

    Which approach works the best will depend somewhat on your particular application needs.

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

Sidebar

Related Questions

I am a newbie to iPhone app development. I want to make a simple
I am a newbie in iPhone development, doing my first app. I have some
I am a newbie to iphone development and i am doing a simple app
I am a newbie to iphone development and i am doing a simple app
Please help a newbie to iPhone development. In my app, I do this a
I am a newbie on iPhone development. I have declared a variable on my
I'm developing a reference iPhone app that will contain many photos (ball park estimate
I am a newbie to iPhone development and have some basic questions to ask
Possible Duplicate: IBOutlet and IBAction I am a newbie to iphone development and have
I have just re-designed my iPhone app using Storyboard... questin is: how do I

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.