Hi,
In latest StepTalk update I had a problem finding whether receiver knows about a
variable with a given name. I do not care whether it is a real ivar or not. I
have used following code:
NS_DURING
/* test whether variable is an ivar s*/
obj = [receiver valueForKey:varName];
NSDebugLLog(@"STCompiler", "New name: receiver variable %@",
varName);
[receiverVars addObject:varName];
NS_HANDLER
if([[localException name] isEqualToString:NSUnknownKeyException])
{
NSDebugLLog(@"STCompiler", "New name: extern %@", varName);
/* receiver has no such variable */
[externVars addObject:varName];
}
else
{
[localException raise];
}
NS_ENDHANDLER
Basically, what I do is to try to get a value for given key. If it exists, then
I assume that the receiver has that ivar.
Is there a better and cleaner way of doing that?
Thanks for any hints,
Stefan Urbanek
p.s.: GNUstep has NSUnknownKeyException where Cocoa has NSUndefinedKeyException,
I think that for compatibility reasons we should have the second instead.
--
http://stefan.agentfarms.net
First they ignore you, then they laugh at you, then they fight you, then
you win.
- Mahatma Gandhi
_______________________________________________
Gnustep-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnustep-dev