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

The Archive Base Latest Questions

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

I have a small doubt. I have a NSObject class where I am trying

  • 0

I have a small doubt. I have a NSObject class where I am trying to display an alert view. So after the alert view is displayed when I tap on OK button I want to push a navigation controller onto the stack. Can I push a navigation controller from general NSObject class? Please let me know guys..thanks for your time..

This is the code..

- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex{    
  SettingsViewController *homeView = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];
    [self.navigationController pushViewController:homeView animated:NO];
    [homeView release];

}

I am creating a property called navigationController of type UINavigationController and when I catch the error I am displaying an alert view and I am using above method to push the view controller but it doesn’t work..

  • 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-16T21:41:06+00:00Added an answer on May 16, 2026 at 9:41 pm

    Yes and no… depending on how you have your application set up. To push views onto the navigation stack you need to have a navigation controller.

    Does your NSObject have access to this navigation controller – you might have to set up a delegate method that gets called from your delegate view when the alert view delegate gets called in your NSObject.

    I’m just wondering why you’re displaying a UIAlertView in an NSObject, why aren’t you displaying it in a UIView or a UIViewController?

    CustomObject.h

    @protocol CustomObjectDelegate<NSObject>
    @optional
    - (void)customObjectAlertViewDidClickOk;
    @end
    
    @interface CustomObject : NSObject <UIAlertViewDelegate>{
        id<CustomObjectDelegate> delegate;
    }
    @property (nonatomic, assign) id<CustomObjectDelegate> delegate;
    @end;
    

    CustomObject.m

    @synthesize delegate;
    // then put this:
    - (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
        [delegate customObjectAlertViewDidClickOk];
    }
    

    Then your ViewController .h file needs to include the custom object and assign the delegate methods:

    #include "CustomObject.h"
    @interface MyViewController : UIViewController <CustomObjectDelegate> {
    
    }
    @end
    

    and the .m viewDidLoad (or similar):

    - (void)viewDidLoad{
        CustomObject *obj = [[CustomObject alloc] init];
        [obj setDelegate:self];
    }
    - (void)customObjectAlertViewDidClickOk{
        AnotherViewController *page = [[AnotherViewController alloc] initWithNibName:nil bundles:nil];
        [self.navigationController pushViewController:page];
    }
    

    Thats how I would do it – given I’m not too sure i understand quite what you’re asking. 🙂 thats all off the top of my head as well – so don’t take it letter for letter, but you have the basis there to start off with. You can build on it. Look up @protocols and delegate methods, its all in there. 🙂

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

Sidebar

Related Questions

I have small page which has label, DropDownList and a submit button. <div> <asp:label
I have small problem with my .net 2.0 winforms application. I want to embed
Where I work, we have small teams of 2 - 5 people. As a
I have a small JS function that does Ajax for me and another like
I have a small utility that I use to download an MP3 file from
I have a small local network. Only one of the machines is available to
I have a small VB.NET application that I'm working on using the full version
I have a small diagnostic VB.Net application ( 2 forms, 20 subs & functions)
I have a small application I am working on that at one point needs
We have a small embedded system without any video or serial ports (i.e. we

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.