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

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 106', 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ả | Implementing a category You implement the methods of the category in an implementation file like this 1 import 2 3 @implementation Circle Motion 4 - void moveRight float dx . 5 - void moveUp float dy . 5 @end Line 1. You need to include the declaration of the category you are implementing. If the declaration is in the same file as the implementation you don t need this line. Line 3. Specify the name of the modified class and the name of your category. Line 4. Methods take the same form and have the same access to fields as in a regular class implementation. Line 5. No semicolon after the @end keyword. Protocols Protocols are lists of method declarations that are not associated with a specific class declaration. Protocols let you express that unrelated classes share a common set of method declarations. This facility inspired Java s interface construct. Protocols let you do the following Use static type checking where you want it Specify interfaces to other code Factor common features of your class hierarchy Objective-C declarations can specify that an instance must support a protocol instead of or in addition to conforming to a class. See Section . Declaring a protocol You declare a protocol in a header file like this 1 @protocol AnotherProtocol 2 3 @protocol Printable Drawable 4 - void print 5 @end Line 1. You need the forward protocol declaration if return or parameter types of methods in your protocol use the other protocol. Protocol names have their own namespace so a protocol can have the same name as a class or a category. Line 3. If your protocol extends other protocols name those in the protocol list. The list is a sequence of protocol names separated by commas. If the list is empty you can omit the angle brackets. You don t need to redeclare the methods of the listed protocols. When a class adopts the protocol you are declaring it must implement all the methods declared in your protocol and all the other protocols in the

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.