Re: Obtaining an array of the names of the attributes and relations of a class
Re: Obtaining an array of the names of the attributes and relations of a class
- Subject: Re: Obtaining an array of the names of the attributes and relations of a class
- From: Francis Derive <email@hidden>
- Date: Tue, 22 Nov 2005 11:21:14 +0100
On Nov 22, 2005, at 12:40 AM, Scott Anguish wrote:
Ah, sorry.
You can't use that class to investigate what attributes are
available for a class.
It is where was my misunderstanding : I thought/beleived/hoped that
NSClassDescription would provide the class description info
"freely" (as it is the case with the Objective-C runtime functions
pointed to by mmalcomm, or with the Core Data's NSEntityDescription
pointed to by John Timmer ) - just because everything of a class is
known to the system through its class declaration.
So we need first to feed (again) NSClassDescription through a
subclass of it - for the instances variables of the particular class/
object we have at hand - and then we can be rewarded later.
In my toy example, I would do :
@interface MYobjectDescription : NSClassDescription {
}
- (NSArray *) attributeKeys;
@end
@implementation MYobjectDescription
- (id) init {
if (self = [super init]) {
;
}
return self;
}
- (NSArray *) attributeKeys {
return [NSArray arrayWithObjects:@"myInstance", @"myOtherInstance",
nil];
}
@end
And later :
MYobjectDescription *desc = [[MYobjectDescription alloc] init];
NSLog(@" les attributs %@", [desc attributeKeys] );
Perhaps I would register MYobjectDescription for the class MYobject,
and any object would read the NSClassDescription cache for MYobject
class description.
In fact, I had imagined that could be the way to do and to understand
NSClassDescription, but couldn't believe it - with no evidence of any
added value in a toy example.
What is left to me is to find and learn situations where this
approach is to be useful - I am warned NSScriptClassDescription is
the case.
To all of you who have been very patient to keep me on the right
path, I say many thanks and I still remain open to your lessons.
Cheers.
Francis.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden