Re: Language Analysis
Re: Language Analysis
- Subject: Re: Language Analysis
- From: Enrique Zamudio <email@hidden>
- Date: Thu, 7 Jun 2001 00:06:16 -0500
Here are a few guildelines for OOP in ObjC:
1) The distinction between a class and its instances is very important,
and so is the difference between class methods and instance methods.
2) Protocols are just that, a means of defining a way to communicate with
an object. For example, if you write a screen saver that supports plugins,
the best way to communicate with the objects in the plugins would be to
define a protocol for a screen saver module. You don't know what object
classes you're going to be talking to when you write your screen saver,
but with the protocol you can specify the methods that you need the
plugins to implement so that you can talk to them.
3) Categories are a way to extend existing classes. Let's say that you
want to have NSStrings that know how to separate themselves into lines or
something. you could write a subclass, but all the Cocoa classes use
NSString and not your subclass. Maybe you could make your class pose as
NSString but it's a bit tricky. So a simple way to achieve this is to
write a category on NSString that defines the methods you need, and voila!
all the NSStrings in your application will know how to do the new stuff.
This is not really a language analysis but I hope it helps you understand
and use ObjC better.
Enrique Zamudio Lopez
Chief Software Architect
North American Software
email@hidden
www.nasoft.com.mx