Search code examples
iphoneobjective-ciosxcodeipad

NSDictionary flatten hierarchy


I've got an NSDictionary object like this:

dictionary: {
    data =     {
        "access_token" = "xxx";
        "expires_in" = 00;
        "refresh_token" = "yyy";
        "token_type" = bearer;
    };
}

How can I flatten it so that I remove the 'data' object? Is there a quick way to do that? So the output should look like this:

dictionary: {

        "access_token" = "xxx";
        "expires_in" = 00;
        "refresh_token" = "yyy";
        "token_type" = bearer;
};

Solution

  • NSDictionary *dataDict = [mainDict  objectForKey:@"data"];