-
对数组里面的字符串做大小写转换 注:只对字符串有效
NSArray *array = @[@"XIAOming", @"xiaohua", @"zhangshan", @"lisi", @"777"];
NSLog(@"%@", [array valueForKey:@"uppercaseString"]);
NSLog(@"%@", [array valueForKey:@"lowercaseString"]);
-
返回每个字符串长度的组成的数组 注:只对字符串有效
NSArray *array = @[@"XIAOming", @"xiaohua", @"zhangshan", @"lisi", @"777"];
NSLog(@"%@", [array valueForKey:@"length"]);
NSArray *array = @[@"1", @"1", @1, @"hehe"];
NSLog(@"\n%@\n%@\n%@\n%@",
[array valueForKeyPath:@"@sum.floatValue"],
[array valueForKeyPath:@"@avg.floatValue"],
[array valueForKeyPath:@"@max.floatValue"],
[array valueForKeyPath:@"@min.floatValue"]);
NSArray *array = @[@"1", @"1", @1, @"hehe"];
NSLog(@"%@", [array valueForKeyPath:@"@distinctUnionOfObjects.self"]);
NSArray *array = @[@{@"name" : @"xiaoming",
@"code" : @1},
@{@"name": @"judy",
@"code" : @2},
@{@"name": @"judy",
@"code" : @3},
@{@"name": @"xiaohua",
@"code" : @4},
@{@"name": @"xiaoming",
@"code" : @4}];
NSLog(@"%@", [array valueForKeyPath:@"name"]);
NSArray *array = @[@{@"name" : @"xiaoming",
@"code" : @1},
@{@"name": @"judy",
@"code" : @2},
@{@"name": @"judy",
@"code" : @3},
@{@"name": @"xiaohua",
@"code" : @4},
@{@"name": @"xiaoming",
@"code" : @4}];
NSLog(@"%@", [array valueForKeyPath:@"@distinctUnionOfObjects.name"]);
NSArray *temp1 = @[@3, @2, @2, @1];
NSArray *temp2 = @[@3, @4, @5];
NSLog(@"\n%@",[@[temp1, temp2] valueForKeyPath:@"@distinctUnionOfArrays.self"]);
NSLog(@"\n%@",[@[temp1, temp2] valueForKeyPath:@"@unionOfArrays.self"]);