操纵NSDictionary数据

时间:2015-07-21 14:42:14

标签: ios objective-c json

我设法将以下数据(乘以数百)导出到NSDictionary中。我现在需要构建一种方法将这些数据放入Tinder风格的应用程序中。任何人都可以建议我如何让我的应用程序针对各种索引针对密钥“标题”提取数据。目前,它提取了45条包含该标题的数据记录,因为我的数据集中有45个密钥。

    {

    AttachmentFiles =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/AttachmentFiles";

        };

    };

    Attachments = 0;

    AuthorId = 22;

    AverageRating = "<null>";

    BestAnswerId = "<null>";

    Body = "We need to think xyz";

    CategoriesLookupId = 16;

    Community = "<null>";

    ContentType =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/ContentType";

        };

    };

    ContentTypeId = 0x01200200C5BB1FEE2601B9439CD527C288D85A7B;

    Created = "2014-03-21T08:37:33Z";

    DescendantLikesCount = 8;

    DescendantRatingsCount = "<null>";

    DiscussionLastUpdated = "2014-06-19T12:57:58Z";

    EditorId = 96;

    EmailSender = "<null>";

    FieldValuesAsHtml =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/FieldValuesAsHtml";

        };

    };

    FieldValuesAsText =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/FieldValuesAsText";

        };

    };

    FieldValuesForEdit =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/FieldValuesForEdit";

        };

    };

    File =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/File";

        };

    };

    FileSystemObjectType = 1;

    FilterCategory = "<null>";

    FirstUniqueAncestorSecurableObject =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/FirstUniqueAncestorSecurableObject";

        };

    };

    Folder =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/Folder";

        };

    };

    GUID = "28144fd4-84b0-434b-9e99-01d939e6a773";

    Has20likes = "<null>";

    ID = 3;

    Id = 3;

    IsFeatured = 0;

    IsIdeaCreated = "<null>";

    IsQuestion = 0;

    LastReplyById = 49;

    LikesCount = 5;

    MemberLookupId = 7;

    Modified = "2015-03-11T15:25:20Z";

    "OData__UIVersionString" = "2.0";

    ParentItemEditorId = "<null>";

    ParentItemID = "<null>";

    ParentList =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/ParentList";

        };

    };

    Popularity = "7.23632608186099";

    RatingCount = "<null>";

    RoleAssignments =         {

        "__deferred" =             {

            uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/RoleAssignments";

        };

    };

    StepChangePillar = "<null>";

    Title = "JIRA Governance";

    "__metadata" =         {

        etag = "\"14\"";

        id = "Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)";

        type = "SP.Data.Community_x0020_DiscussionListItem";

        uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)";

    };

},

谢谢

1 个答案:

答案 0 :(得分:1)

你应该有一系列字典正确吗?

若是,这应该有效:

NSInteger index = 0; //You can set this to the current page of your scroll view
NSArray * items = /* YOUR ARRAY OF DICTIONARIES */;
NSDictionary * dict = [items objectAtIndex:index];
NSString * title = [dict objectForKey:@"Title"];

您可能还考虑创建NSObject的子类并在字典的解析器中构建,以便您可以访问具有强类型的变量。