0

I have a json array that I'm trying to extract data from. The array was created using NSJSONSerialization. Here is what the json array looks like from NSLog([jsonArray debugDescription]);:

{
    properties =     (
                {
            ID = 12345;
            PropertyName = "McDonalds";
            key = 00112233445566778899aabbccddeeff;
        },
                {
            ID = 12346;
            PropertyName = "Taco Bell";
            key = 00112233445566778899aabbccddeef0;
        },
                {
            ID = 12347;
            PropertyName = "Burger King";
            key = 00112233445566778899aabbccddeef1;
        }
    );
    success = 1;
    totalCount = 3;
}

I need to extract each ID and each Property name and dump the values into separate arrays. How can I do this?

1 Answer 1

3

You can use Key-Value Coding:

NSArray *ids = [jsonArray valueForKeyPath:@"properties.ID"];
NSArray *propertyNames = [jsonArray valueForKeyPath:@"properties.PropertyName"];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.