摘录自:OSCHINA Megan_zhou http://my.oschina.net/megan/blog/133918
这个太简单, 没什么好说的,直接上例子:
NSArray *testArray = [NSArray arrayWithObjects:@"2.0", @"2.3", @"3.0", @"4.0", nil];
NSNumber *sum = [testArray valueForKeyPath:@"@sum.floatValue"];
NSNumber *avg = [testArray valueForKeyPath:@"@avg.floatValue"];
时间: 2024-11-11 13:50:15