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

Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 29', 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ả | Safely Threading with Core Data 249 In order to implement a subclass of NSOperation at a minimum you need to implement a custom initializer method that you use to configure your object for use and a main method that will perform the task. You can also implement any other custom methods that you need such as accessor methods to get at the operation s data or dealloc to free memory allocated by the operation. Once you have created your operation classes you need to tell the system to execute them. You accomplish this by creating an instance of NSOperationQueue and adding your NSOperation subclasses to the queue. The system uses operation queues to schedule and execute your operations. The system manages the queues which handle the details of scheduling and executing your threads for you. It is possible to configure dependencies between operations when adding operations to an operation queue. You can also prioritize operations when you add them to a queue. Core Data Threading Example As I mentioned this example application will generate five random numbers and pause for 1 second between each number to simulate a time consuming synchronous operation. This code will block the main thread causing the user interface to become unresponsive while you are generating the random numbers. Then you will take the random number generation and move it on to its own thread. Once you do this you will see that the user interface remains responsive while you generate the random numbers. 3 In this example you will be inserting data into the Core Data context on an off thread. This is generally not recommended however I am doing it in this example to demonstrate the mechanics of threading with Core Data. In production applications you should generally only use threads to perform time consuming reads and queries from Core Data and not to perform inserts or updates. To get started open Xcode and start a new Navigation-based application. Make sure that Use Core Data for storage is checked.

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.