TAILIEUCHUNG - Phát triển ứng dụng cho iPhone và iPad - part 27

Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 27', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Key-Value Observing 229 passes in to determine which property has changed. Then you use that knowledge to set the text of the appropriate label. In the viewDidUnload method you need to remove the KVO observers. You also set the properties of the class to nil. Here is the code for viewDidUnload Available lor download on void viewDidUnload Release any retained subviews of the main view. Tear down KVO for the umpire counter removeObserver self forKeyPath @ balls removeObserver self forKeyPath @ strikes removeObserver self forKeyPath @ outs nil nil nil nil super viewDidUnload Once again you make a call to the umpireCounter object. This time you call the removeObserver forKeyPath method to remove your class as an observer of the umpirecounter. You call this method once for each property that you are observing passing self as the observer each time. Then you set each property to nil and call the superclass implementation of viewDidUnload. While you are writing cleanup code implement the dealloc method to release all of your instance variables and call the superclass dealloc method Available for download on void dealloc ballLabel release strikeLabel release outLabel release umpireCounter release super dealloc Updating Values with Key-Value Coding The last thing that you need to do is implement the buttonTapped method that executes each time the user taps one of the buttons in the interface. Instead of specifically setting the property 230 CHAPTER 8 CORE DATA-RELATED COCOA FEATURES values of the umpirecounter using dot notation you will use KVC in conjunction with the title of the button that was pressed to set the appropriate value. You also need to implement some business logic to limit the ball counter to a maximum of 3 and the strike and out counters to a maximum of 2. Here is the code

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.