Domanda

I try to NSLog the name of the presenting view controller:

NSLog(@"presentingViewController is: %@", self.presentingViewController);

but all I get is: "presentingViewController is: UITabBarController: 0x71393d0"

I know I need to create an description but I don't know how and where. I don't have a custom class for the UITabBarController.

Thanks for you help and don't beat me up for question which might be too easy for pros.

È stato utile?

Soluzione

Without custom class you could overwrite the method in the UITabBarController with a category.

Example:

//UITabBarController+Description.m
@implementation UITabBarController+Description (UITabBarController)

- (NSString *)description {
    NSString *output = [NSString stringWithFormat:@"The tabBarController with backgroundImage: %@",     self.tabBar.backgroundImage];
    return output; 
}
@end

Documentation from Apple here: https://developer.apple.com/library/ios/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top