1

私の HTTPClient は AFRESTClient サブクラスであり、コア データに AFIncrementalStore を使用しています。

私の応答は、エンティティの「content_id」として一意の識別子を持っています。オーバーライドしました

resourceIdentifierForRepresentation:(NSDictionary *)representation
ofEntity:(NSEntityDescription *)entity
fromResponse:(NSHTTPURLResponse *)response

私のhttpclientでエンティティの「content_id」を返しましたが、フェッチは1つのアイテム(配列の最後のアイテム)しか取得しません。

ただし、応答に「id」パラメーターがある場合は正常に機能します。

残りのクライアントの resourceIdentifier をオーバーライドできないはずですか、それとも何か不足していますか?

4

1 に答える 1

0

やっとわかった

文字列化された一意の値を返す必要があるresourceIdentifierの定数文字列値を返していました。

今、私は一意の値の説明を返し、正常に動作します

- (NSString *)resourceIdentifierForRepresentation:(NSDictionary *)representation
                                         ofEntity:(NSEntityDescription *)entity
                                     fromResponse:(NSHTTPURLResponse *)response
{
    NSString *resourceIdentifier = [super resourceIdentifierForRepresentation:representation ofEntity:entity fromResponse:response];

    if([entity.name isEqualToString:@"MyEntity"])
    {
        resourceIdentifier = [[representation objectForKey:CONTENT_ID] description];
    }
    return resourceIdentifier;
}

以前はresourceIdentifier = CONTENT_IDを返しました

ここで明確にしてくれた Matt Thompson に感謝します - (Matt のコメントを参照) https://github.com/AFNetworking/AFIncrementalStore/issues/211

于 2013-06-18T21:46:40.057 に答える