문제

I have a NSDictionary (coming from a JSON object)
One of the key/value is an array I'm trying to get it using the following:

NSArray *ingArr = [item objectForKey:@"ingredients"];

using watch I can see that "item[ingredients]" is:

<__NSCFArray 0xc728cb0>(
{
    amount = "3 tablespoons";
    name = "soy sauce";
    "short_name" = "soy sauce";
},
{
    amount = "1 tablespoon";
    name = honey;
    "short_name" = honey;
},
{
    amount = "1 tablespoon";
    name = "vegetable oil";
    "short_name" = "vegetable oil";
},
{
    amount = "1 teaspoon";
    name = "lime juice";
    "short_name" = "lime juice";
},
{
    amount = "1 teaspoon";
    name = "chopped garlic";
    "short_name" = garlic;
},
{
    amount = 4;
    name = "skinless, boneless chicken breast halves";
    "short_name" = chicken;
}
)

My problem is that ingArr doesn't contain the expected result. What I get when I'm trying to watch ingArr[0] is:

(<invalid>) [0] = <error: expected ']'
error: 1 errors 
>
도움이 되었습니까?

해결책

This seems to be an Xcode bug (and I have seen similar problems in the "Debugger Variables" view). As an alternative, use

po ingArray[0]

in the Debugger Console, which works reliably (or, of course, NSLog() in your program code).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top