[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to learn more about methods in Object.h (was Re: Class
From: |
Paul Johnson |
Subject: |
How to learn more about methods in Object.h (was Re: Class |
Date: |
Mon, 17 Apr 2000 10:50:15 -0500 |
address@hidden wrote:
In particular, the isKindOf method works in just
> the manner described (except the method name is "class" and not
> "Class"). Here's how I use it in one of my models:
>
> - (void) updatePopulationCount
> {
> int x,y;
> int maxX = [data_source getSizeX];
> int maxY = [data_source getSizeY];
>
> [self resetPopulationCount];
>
> for (x=0; x < maxX; x++) {
> for (y=0; y < maxY; y++) {
> // Count the number of each kind of agent we have
> id agent = [data_source getObjectAtX: x Y: y];
> if ( [agent isKindOf: [MimicBestNeighborAgent class]] )
> class_count[MIMIC_BEST_NEIGHBOR]++;
> }
> }
>
> // Irrelevant stuff deleted
>
> }
> --
> Jason Alexander
> Logic & Philosophy of Science email: address@hidden
This is an extremely useful post. Thanks much.
I'm looking at the header file Object.h and I see a bunch of methods
like isKindOf: and I wonder where to find more documentation about
them. I'd like to know what they return, how to use what they return,
etc. Here are some for which I would like to have explanations and
usage examples:
/* Creating, freeing, and copying instances */
+ new;
+ alloc;
- free;
- copy;
- shallowCopy;
- deepen;
- deepCopy;
/* Identifying classes */
- (Class)class;
- (Class)superClass;
- (MetaClass)metaClass;
- (const char *)name;
/* Identifying and comparing objects */
- self;
- (unsigned int)hash;
- (BOOL)isEqual:anObject;
- (int)compare:anotherObject;
/* Testing object type */
- (BOOL)isMetaClass;
- (BOOL)isClass;
- (BOOL)isInstance;
/* Testing inheritance relationships */
- (BOOL)isKindOf:(Class)aClassObject;
- (BOOL)isMemberOf:(Class)aClassObject;
- (BOOL)isKindOfClassNamed:(const char *)aClassName;
- (BOOL)isMemberOfClassNamed:(const char *)aClassName;
/* Testing class functionality */
+ (BOOL)instancesRespondTo:(SEL)aSel;
- (BOOL)respondsTo:(SEL)aSel;
/* Testing protocol conformance */
- (BOOL)conformsTo:(Protocol*)aProtocol;
/* Introspection */
+ (IMP)instanceMethodFor:(SEL)aSel;
- (IMP)methodFor:(SEL)aSel;
+ (struct objc_method_description
*)descriptionForInstanceMethod:(SEL)aSel;
- (struct objc_method_description *)descriptionForMethod:(SEL)aSel;
/* Sending messages determined at run time */
- perform:(SEL)aSel;
- perform:(SEL)aSel with:anObject;
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66045 FAX: (785) 864-5700
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
- Class, David Aliaga, 2000/04/17
- Re: Class, jalex, 2000/04/17
- How to learn more about methods in Object.h (was Re: Class,
Paul Johnson <=
- Re: Class, Marcus G. Daniels, 2000/04/17