views:

198

answers:

3

Hello experts!

Let's say I add a new view to my UIWindow

[windowRoot addSubview:MyNewView.view];

Is it possible to retrieve the name of that view later on if I have reference to windowRoot? Something like:

[windowRoot getCurrentViewName]  

Thank You

+3  A: 

UIWindow is a UIView, so you can do something like this to get the subviews of it:

for (UIView *view in windowRoot.subviews) {
    NSLog(@"View: %@", view);
}
rickharrison
A: 

Your question seems to imply a bigger design issue. I assume by "name" you mean the name of the variable referring to new view? That variable should actually be an instance variable of your window controller.

Andy Milburn
Hi Andy! No I actually want the name of the view, not the instance.
jakob
A: 

Hi,

NSUserDefaults *savedData = [NSUserDefaults standardUserDefaults];

NSString *currentPage = [NSString stringWithFormat:@"%@", self.nibName];

[savedData setObject:currentPage forKey:@"lastViewAccessed"];

//self.nibName will get you what you the name of the view.

Ben Call