2013-09-02 3 views
1
내가 제시 뷰 컨트롤러의 이름 NSLog하려고

:NSLog 메모리 주소

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

을하지만 내가 가진 전부입니다 : "presentingViewController은 다음과 같습니다 UITabBarController가 : 0x71393d0"

나는이를 만들 필요가 알고 설명하지만 어떻게 그리고 어디서 모르는 지요. UITabBarController에 대한 사용자 지정 클래스가 없습니다. 당신이 도움을 전문가를위한 너무 쉽게 수 있습니다 질문에 대한 나를 이길하지 않습니다에 대한

감사합니다.

+1

, 그냥 방법을 UITabBarController가에 범주를 만들고 오버라이드 (override) : - (있는 NSString *)는 설명 –

답변

2

는 사용자 정의 클래스없이 당신은 카테고리와 UITabBarController가있는 방법을 덮어 쓸 수 있습니다.

예 :

여기에 애플의 문서
//UITabBarController+Description.m 
@implementation UITabBarController+Description (UITabBarController) 

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

: 빅토르는 지적 https://developer.apple.com/library/ios/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html

+1

이 더 나은 수행 가능하다면 서브 클래스에서. Apple이 카테고리 (즉, 합법적이고 SDK에서 SDK로 자유롭게 변경할 수 있으며 개발자가 쉽게 감지하지 못하는)에서'-description '을 구현하면 위의 정의되지 않은 동작입니다. 범주는 메서드를 재정의하고 메서드를 재정의하는 것이 아닙니다. –