Differences From Artifact [2d002f2918]:
- File
src/OFArray.m
— part of check-in
[05196e511a]
at
2016-06-05 15:00:33
on branch trunk
— Implement Key Value Coding for OFArray
If the key starts with an @, the @ is stripped and the super method is
called. Otherwise, this returns the value for all objects / sets the
value for all objects. (user: js, size: 17497) [annotate] [blame] [check-ins using]
To Artifact [b96b2adef7]:
- File
src/OFArray.m
— part of check-in
[134c19b100]
at
2016-06-05 20:07:30
on branch trunk
— Fix -[OFArray valueForKey:]
Contrary to what the documentation stated, it did not actually call
super when the key was starting with an @. (user: js, size: 17993) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
274 275 276 277 278 279 280 | - (id)objectAtIndexedSubscript: (size_t)index { return [self objectAtIndex: index]; } - (id)valueForKey: (OFString*)key { | > > > > > > > > > > > > > > | > > > > > > > > > > > | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | - (id)objectAtIndexedSubscript: (size_t)index { return [self objectAtIndex: index]; } - (id)valueForKey: (OFString*)key { OFMutableArray *ret; if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); id ret; key = [key substringWithRange: of_range(1, [key length] - 1)]; ret = [[super valueForKey: key] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } ret = [OFMutableArray arrayWithCapacity: [self count]]; for (id object in self) { id value = [object valueForKey: key]; if (value == nil) value = [OFNull null]; [ret addObject: value]; } [ret makeImmutable]; return ret; } - (void)setValue: (id)value forKey: (OFString*)key { if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); key = [key substringWithRange: of_range(1, [key length] - 1)]; [super setValue: value forKey: key]; objc_autoreleasePoolPop(pool); return; } if (value == [OFNull null]) value = nil; for (id object in self) [object setValue: value forKey: key]; } |
︙ | ︙ |