连续获取字典的key值

- (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;
}

你可能感兴趣的:(连续获取字典的key值)