This link has been bookmarked by 30 people . It was first bookmarked on 25 Jul 2006, by Zhe sto.
-
-
One unique aspect of Objective-C's interface system is how you specify types. Rather than specifying it like Java or C++ as: Printing *someVar = ( Printing * ) frac; for example, you use the id type with a restricted protocol: id <Printing> var = frac; This allows you to dynamically specify a type that requires multiple protocols, all with one variable. Such as: id <Printing, NSCopying> var = frac;
-
-
-
- The protocol specification is quite simple. it is basically @protocol ProtocolName (methods you must implement) @end.
- To conform to a protocol, you put the protocols you're conforming to in <>'s, and comma separate them. Example: @interface SomeClass <Protocol1, Protocol2, Protocol3>
- The methods that the protocol requires to be implemented are not required to be in the list of methods for the header file. As you can see, Complex.h doesn't have a definition for -(void) print, but it still implements it since it conforms to the protocol.
- One unique aspect of Objective-C's interface system is how you specify types. Rather than specifying it like Java or C++ as: Printing *someVar = ( Printing * ) frac; for example, you use the id type with a restricted protocol: id <Printing> var = frac; This allows you to dynamically specify a type that requires multiple protocols, all with one variable. Such as: id <Printing, NSCopying> var = frac;
- Much like using @selector for testing an object's inheritance, you can use @protocol to test for conformance of interfaces. [object conformsToProtocol: @protocol( SomeProtocol )] returns a BOOL if the object conforms to that protocol. This works the same for classes as well: [SomeClass conformsToProtocol: @protocol( SomeProtocol )].
-
-
Arrix ZBeginner's guide to Objective-C with practical coding examples that contrast Objective-C to other OOP languages like Java and C++
-
Categories are useful for creating private methods. Since Objective-C has no notion of private/protected/public methods like java does, one has to create categories that hide such functionality.
-
-
-
All the source code for this beginners guide including makefiles is available by downloading objc.tar.gz. Many of the examples in this tutorial were written by Steve Kochan in the book "Programming in Objective-C." If you want more detailed information and examples, feel free to check out his book. The examples on this site were used with his permission, so please don't copy them.
-
All the source code for this beginners guide including makefiles is available by downloading objc.tar.gz. Many of the examples in this tutorial were written by Steve Kochan in the book "Programming in Objective-C." If you want more detailed information and examples, feel free to check out his book. The examples on this site were used with his permission, so please don't copy them.
- 1 more annotations...
-
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.