TAILIEUCHUNG - HandBooks Professional Java-C-Scrip-SQL part 120

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 120', 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ả | Line 1. Declare the method as specified by the NSCoding protocol. Cocoa s archiving methods will pass in the coder object to your encode method. Line 2. Call super only if the parent class also implements the NSCoding protocol. In this example the parent class is NSObject which doesn t implement the protocol so this line of code is commented out. Line 3. If the field is an Objective-C object pass it to the coder using the -encodeObject method. Line 4. If the field is a C type use the -encodeValueOfObjCType method shown here. The @encode directive constructs a string describing the structure of the specified type which tells the coder how to process the value. The coder stores the string along with the value to facilitate decoding. Line 5. Instead of directly passing the value you want to store you pass its address. To read the fields of MyClass implement the following method 1 - void initWithCoder NSCoder coder 2 if self super initWithCoder coder 3 int version 4 coder versionForClassName @ MyClass 5 Check version here. 6 obj coder decodeObject retain 7 coder decodeValueOfObjCType @encode int 8 at i 9 10 Line 1. Declare the method to conform to the NSCoding protocol. Cocoa s archiving methods will pass in the coder object to your decoding method. Line 2. Call super only if the parent class also implements the NSCoding protocol. If the parent class does not implement the NSCoding protocol call its designated initializer instead. In either case assign the result to self because the parent class may return a different object than itself. Lines 3 4. Get the class s version number which the coder automatically stores with the object information. Line 5. Depending on the version number you may have to vary the implementation of the rest of the method. Line 6. To retrieve an Objective-C object call the coder s -decodeObject method. You must decode objects in the same order you encoded them in the -encodeWithCoder method. When you get a value from -decodeObject you should .

Đã 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.