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

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 111', 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ả | Each method takes as a parameter a pointer to an NSZone which isn t a class but an opaque type. Normally you will not look any deeper into the zone parameter but pass it along to an inherited copy method like -allocWithZone or a Cocoa runtime function like NSZoneAlloc . See the Cocoa documentation for information on how to use the runtime functions for allocating memory. Since NSObject does not implement either protocol you must adopt and implement the protocols if you want your objects to support copying. Your class will inherit from NSObj ect whose methods -copy and -mutableCopy call the respective protocol methods with nil parameters so you can use those simpler methods to make copies of your class s instances. If the distinction between mutable and immutable doesn t matter for your class all instances are mutable or all are immutable just adopt NSCopying. If instances may be one or the other kind adopt both NSCopying and NSMutableCopying using the first for returning immutable copies and the second for mutable ones. If your class doesn t inherit any -copyWithZone method implement it using allocWithZone and an initialization method. For example - id copyWithZone NSZone zone return self class allocWithZone zone init In this example you evaluate self class to get the receiver of the allocation message. Don t use the name of your class here. If you do descendants won t be able to inherit this method because the kind of object it creates will be hard-wired. If your class inherits a -copyWithZone method you might not need to change it for example if your class doesn t add any fields. If you do override this method it should first call the same method on super before doing any further work. For example - id copyWithZone NSZone zone MyClass copy super copyWithZone zone Further class-specific setup of copy. return copy If the inherited method returns a shallow copy the copy will have two properties you will have to correct Its reference count will be identical to your .

TÀI LIỆU MỚI ĐĂNG
Đã 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.