[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Casting an id type to a specific object type?
From: |
Jae Chan Oh |
Subject: |
Casting an id type to a specific object type? |
Date: |
Fri, 14 Mar 1997 01:23:46 -0500 (EST) |
Hi Glen,
This question is in the same thread as the second question of my
last email about updateEnergy method in my program.
Say, in a method,
I have a delcation:
-myMethd {
(id) tgt;
bool status;
if (((tgt = [world getObjectAtX: x1 Y: y1]) != nil))
status = [tgt isItAlive];
// some stuff .......
}
Let's say "isItAlive" is a method of "Person" type. I get core dump
at "status = [tgt isItAlive]" line since objc_msg_lookup
can't find the method. I have tried to declare tgt as pointer to
Person i.e.: Person * tgt. And tried many other things but no luck.
How do I cast tgt to Person type so it can recognize the method "isItAlive"?
Should using protocol would help?
i.e. declaring tgt as "(id <PersonProtocol>)" tgt would help?
I'd like to avoid delcaring protocol if possible.
FYI, the following is gdb error messages after the crash:
(gdb) where
#0 objc_msg_lookup (receiver=0x368b00, op=0x278d10) at sarray.h:216
#1 0x41c2c in _i_Person__look (self=0x368880, _cmd=0x278b48) at Person.m:353
#2 0x404e0 in _i_Person__step (self=0x368880, _cmd=0x27934c) at Person.m:50
Thank you,
-Jae
- Re: "zone" or "getZone"? and one additiona question., (continued)
- "zone" or "getZone"? and one additiona question., glen e. p. ropella, 1997/03/14
- Re: "zone" or "getZone"? and one additiona question., Jae Chan Oh, 1997/03/15
- Re: "zone" or "getZone"? and one additiona question., Ken Cline, 1997/03/15
- Re: "zone" or "getZone"? and one additiona question., glen e. p. ropella, 1997/03/17
- Tcl Script Error, Jae Chan Oh, 1997/03/19
- Message not available
- Re: Tcl Script Error, Manor Askenazi, 1997/03/19
- Re: Tcl Script Error, glen e. p. ropella, 1997/03/20
- Thanks all & -updateLattice Method, Jae Chan Oh, 1997/03/17
- Casting an id type to a specific object type?,
Jae Chan Oh <=
- Re: Casting an id type to a specific object type?, Ken Cline, 1997/03/14
- Re: Casting an id type to a specific object type?, Jae Chan Oh, 1997/03/15
- Re: Casting an id type to a specific object type?, Ken Cline, 1997/03/15
- Re: Casting an id type to a specific object type?, mcmullin, 1997/03/17
- Re: Casting an id type to a specific object type?, mcmullin, 1997/03/17