43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
@implementation OFObject (KeyValueCoding)
- (id)valueForKey: (OFString*)key
{
SEL selector = sel_registerName([key UTF8String]);
const char *typeEncoding = [self typeEncodingForSelector: selector];
id ret;
switch (nextType(&typeEncoding)) {
case '@':
ret = [self performSelector: selector];
break;
#define CASE(encoding, type, method) \
case encoding: \
{ \
|
>
>
>
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
@implementation OFObject (KeyValueCoding)
- (id)valueForKey: (OFString*)key
{
SEL selector = sel_registerName([key UTF8String]);
const char *typeEncoding = [self typeEncodingForSelector: selector];
id ret;
if (typeEncoding == NULL)
return [self valueForUndefinedKey: key];
switch (nextType(&typeEncoding)) {
case '@':
ret = [self performSelector: selector];
break;
#define CASE(encoding, type, method) \
case encoding: \
{ \
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
selector = sel_registerName(name);
free(name);
typeEncoding = [self typeEncodingForSelector: selector];
if (nextType(&typeEncoding) != 'v' || nextType(&typeEncoding) != '@' ||
nextType(&typeEncoding) != ':') {
[self setValue: value
forUndefinedKey: key];
return;
}
valueType = nextType(&typeEncoding);
|
|
|
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
selector = sel_registerName(name);
free(name);
typeEncoding = [self typeEncodingForSelector: selector];
if (typeEncoding == NULL || nextType(&typeEncoding) != 'v' ||
nextType(&typeEncoding) != '@' || nextType(&typeEncoding) != ':') {
[self setValue: value
forUndefinedKey: key];
return;
}
valueType = nextType(&typeEncoding);
|