TAILIEUCHUNG - iPhone Cool Projects phần 5

Phần giao diện mô tả. Lưu các thay đổi trong giao diện Builder, và chúng ta hãy tập trung vào phần thực hiện của ThreadingViewController chúng tôi. Mở tập tin trong Xcode. Chúng ta cần để hoàn thành triển khai thực hiện phương pháp setter getter của chúng tôi và. | 72 CHAPTER 3 Doing Several Things at Once Performance Enhancements with Threading Figure 3-15. Connect the events to the associated buttons. Thread Count 0 Thread Count 0 Start Counting 1 Start Counting 2 Thread Count 0 Thread Count 0 Start Counting 3 start Counting 4 Creating a Thread The interface section is now described. Save the changes in Interface Builder and let s focus on the implementation section of our ThreadingViewController. Open the file in Xcode. We need to complete implementing our getter and setter methods. To do so add the code in Listing 3-2 to the implementation section of the file. Listing 3-2. Completing the Getter and Setter Methods in synthesize totalcount synthesize threadlLabel synthesize thread2Label synthesize thread3Label synthesize thread4Label synthesize buttonlTitle synthesize button2Title synthesize button3Title synthesize button4Title synthesize updatedByThread CHAPTER 3 Doing Several Things at Once Performance Enhancements with Threading 73 We need to look at how to implement our thread when a user wants to launch a thread by clicking a button. Clicking a Start Counting button will trigger an event that will be handled by the corresponding launchThreadX methods. Creating a Worker Thread It is important now to discuss how we are going to implement a worker thread and what the thread is going to do. When the thread is spawned it increments a counter ten times updates its display on the iPhone sleeps after each increment and updates the total thread counter at the end of each cycle. The cycle repeats until the user signals to kill the individual thread or kill all threads by clicking Stop All Counting . See Figure 3-16. performSelectorInBackground @selector thread1 withObject nil thread1 Thread the Needle App performSelectorOnMainThread @selector displayThread1Counts withObject myNumber waitUntilDone YES while button1On I I --T--------------------------I .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.