본문 바로가기

Objective-C

[Objective-C] IOS Cookbook 예제 chapter5-1



1. main 메서드로부터의 실행순서는

TestBedAppDelegate.didFinishLaunchingWithOptions -> TestBedViewController.loadView

view를 띄우기전에 delegator에서 먼저 작업을 진행하고 loadView로 넘기는듯..


2. TestBedViewController.loadView 메서드에서 

    self.navigationController.navigationBar.tintColor = COOKBOOK_PURPLE_COLOR;

    self.navigationItem.rightBarButtonItem = BARBUTTON(@"Right", @selector (rightAction:));

    self.navigationItem.leftBarButtonItem = BARBUTTON(@"Left", @selector(leftAction:));


위 구문이 빠지면, 실행 후 시뮬레이터에는 하얀색바탕과 일반적인 색상의 빈 네비게이션바만 노출이 된다.




3. didFinishLaunchingWithOptions 메서드에서 window.rootViewController를 TestBedViewController로 설정하면 화면은 아래와 같이 된다.



4. didFinishLaunchingWithOptions 메서드의 NavigationController와 loadView 메서드의 self.navigationController는 같은 객체다. (NSLog로..)


5. self.navigationItem 와 self.navigationController.navigationItem은 다른 객체다.

여기서 의문.. 


navigationItem은 navigationController에 속하는것이 아닌가..? 저게 다른 객체인 부분과

실제로 navigationItem에 button을 생성 할 때 

self.navigationController.navigationItem.leftBarButtonItem가 아닌

self.navigationItem.leftBarButtonItem 에 할당하는 것이 잘 이해가 되지 않는다. 심지어 self.navigationController.navigationItem.leftBarButtonItem는 readonly property로 설정되어있다. 어떤 용도일까 저건...


혹시 navigationController 그 자체는 여러 UiViewController의 배열을 가지고 push/pop만 해주는 용도이고.. 실제 각 Stack에 들어가있는 UIViewController가 자기에 맞는 navigationItem을 가지고 있어야하기 때문인건가..?

그렇다면, readonly property인 self.navigationController.navigationItem.leftBarButtonItem등의 용도는..?