1. 易忘方法
[[NSString alloc] initWithContentOfFile: @"/tmp/test"];
2. KVC:
NSString *value = [obj valueForKey:@"key"];
[obj setValue:objValue forKey:@"key"];
NSString *value = [obj valueForKeyPath:@"key1.key2"]; //key1.@count 表示调用getter方法 , key1.@(sum/avg/min/max/distinctUnionOfObjects).key2表示计算数组key1值key2的总和或平均值等等
[obj setValue:objValue forKeyPath:@"key1.key2"];
批量:
[obj dictionaryWithValuesForKeys:arrayKeys];
NSDictionary *newValues = [NSDictionary dictionaryWithObjectsAndKeys:key...., nil];
[obj setValuesForKeysWithDictionary:newValues];
设置nil: 重写setNilValueForKey <null>是的[NSNull null]对象,(null)是nil
处理为定义的键:重写valueForUndefinedKey
字典中setValue:forKey为nil时会删除键,字典不允许setObject:forKey为nil
3. NSPredicate
[NSPredicate predicateWithFormat:@"key=='value' "];
BOOL match = [predicate evaluateWithObject: obj];
[array filteredArrayUsingPredicate: predicate];