views:

69

answers:

1

I am working on an app that has several different views, two of the which are DetailViewController.h&.m and AddViewController.h&.m. Neither of these particular view have IB xib files associated with them, they just have programmatically generated UITableViews. These views essentially are the same, the only difference, is that in the AddViewController, you put info into cells, and in the DetailViewController that same info is viewable and editable. Essentially the viewDidLoad for the AddViewController overrides the DetailViewController viewDidLoad with different navigation bar items and title. MY QUESTION: Outside of IB, how do I reference which view I am in? I want to have some switches and buttons available in the DetailView, that I don't want available in the AddView. But being that as it is, they are refferencing the same info, and currently just changing the navigation bar items, they aren't seperate like I would like them to be. Inside the DetailView viewDidLoad I'm thinking I need something where its like

if(currentView = DetailView) {
self.view addSubview: onOffSwitch;
}
else onOffSwitch. hidden = YES;

Or something to that effect. Obviously if the above code actually worked, I wouldn't be writing this question :) Its probably just a syntax issue I can't hammer out, if you could please help me out, it would be greatly appreciated! Thanks

+1  A: 

Well there is similar question here

But for your case you can do it like:

if([[self class] isKindOfClass:[DetailViewController class]]) {
self.view addSubview: onOffSwitch;
}
else 
onOffSwitch. hidden = YES;
Madhup
Actually, it works perfectly. Thanks!
Steve