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..
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
CustomObject.m
Then your ViewController .h file needs to include the custom object and assign the delegate methods:
and the .m viewDidLoad (or similar):
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. 🙂