0

この JSON ドキュメントを確認してください。

{
"result": {
    "playlists": [
        {
        "name": "p1",
        "songs": [
            {
            "title": "t",
            "artist": "a"
            },
            {
            "title": "t",
            "artist": "a"
            }
        ]
        },
        {
        "name": "p2",
        "songs": [
            {
            "title": "t",
            "artist": "a"
            },
            {
            "title": "t",
            "artist": "a"
            }
        ]
        }
    ] 
}
}

「曲」以外のエンティティを作成せずに、このドキュメントから「曲」のみをマッピングできますか? この場合、プレイリストは気にしません。Song エンティティの RKEntityMapping を作成しました。RKResponseDescriptor を作成するには、すべての "Song" エンティティに一致させるためにどの keyPath を提供する必要がありますか?

「result.playlists.songs」を試しましたが、うまくいきません。

RKEntityMapping *songMapping = [RKEntityMapping mappingForEntityForName:@"Song"
                                                   inManagedObjectStore:[RKManagedObjectStore defaultStore]];

[songMapping addAttributeMappingsFromArray:@[@"title", @"artist"]];

RKResponseDescriptor *songsResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:songMapping
                                                                                       pathPattern:@"/playlists"
                                                                                           keyPath:@"result.playlists.songs"
                                                                                       statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

[[RKObjectManager sharedManager] addResponseDescriptor:songsResponseDescriptor];

RestKit はそれを行うのに十分強力ですか?

「プレイリスト」が配列であり、そのすべてのオブジェクトの「曲」属性を検査する必要があることを指定する方法はありますか?

プレイリストを「PlayList」エンティティと照合する場合、「result.playlists」が機能することはわかっていますが、それをスキップしてさらに深く掘り下げたいと思います。出来ますか?

4

0 に答える 0