Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
You can determine whether an object is a member of a certain class with the isMemberOfClass method. You’ll put that method to use in the next task to verify that a certain object is a member of a certain class, here called Class1. You can get the class’s name simply by sending it the message class like this: [Class1 class].
To use isMemberOfClass:
1. | Create a new program named isMemberOfClass.m. |
2. | |
3. | Add the code to create an object of the Class1 class and verify that the object really is a member of the Class1 class (Listing 6.14). |
4. | Save isMemberOfClass.m. |
5. | Run the isMemberOfClass.m program. You should see the following: c1 is a member of Class1. |