- (id)NsDictValuesForKeyPath:(NSString *)keyPath
{
if (keyPath ==nil &&[keyPath isKindOfClass:[NSString class]] && keyPath.length<=0) {
return nil;
}
NSArray *arr = [keyPath componentsSeparatedByString:@"."];
id tmpDic = nil;
if (arr && arr.count>0)
{
int index = 0;
tmpDic = self;
while (tmpDic && index < arr.count) {
if ([tmpDic isKindOfClass:[NSDictionary class]]) {
tmpDic = [tmpDic objectForKey:arr[index]];
} else {
tmpDic = nil;
break;
}
index++;
}
}
return tmpDic;
}
网友评论