私はRestKit 2.0に少しこだわっています。私は CoreData に User-Entity を持っています。これは ActionStream-Entity との関係を持っています。
ユーザーには、1 対 1 の関係があります。ActionsStream ActionsStream には、1 対多の関係があります。
ユーザーをログインさせると、ActionStream へのアクセスを許可するデータとトークンを取得します。したがって、Json 応答を ActionsStream エンティティにマップする必要があります。
// Example Json ActionsStream with 2 Action items
{
"total_count":2,
"number_of_pages":2,
"current_page":1,
"items":[
{
"id":58606,
"description":"dd "
},
{
"id":58602,
"description":"dd "
}
]
}
私の Action と ActionStream のマッピングは簡単ですが、参照用に追加します。
NSDictionary *mappingDict = @{ @"id" : @"id",
@"description" : @"description" };
NSDictionary *mappingDict = @{ @"total_count" : @"totalCount",
@"number_of_pages" : @"numberOfPages",
@"current_page" : @"currentPage"};
そして、次のようにファイルをロードしたいと考えています。
- (void)loadUserActionss:(User*)user{
RKObjectManager *objectManager = [RKObjectManager sharedManager];
[objectManager addResponseDescriptorsFromArray:@[
[RKResponseDescriptor responseDescriptorWithMapping:[ActivityStream entityMapping:objectManager.managedObjectStore]
method:RKRequestMethodAny
pathPattern:nil
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]
]];
[objectManager getObjectsAtPathForRelationship:@"actionSream"
ofObject:user
parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
NSLog(@"Success");
}failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"Failure");
}];
}
+[RKPathMatcher pathMatcherWithPattern
:]
'NSInternalInconsistencyException', reason: 'パターン マッチングを実行するには、パターン文字列を空にすることはできません。'
私はRestKitを初めて使用するので、状況を正しい方法で処理しており、別の方法を使用する必要があるかどうかなど、ガイダンスが役立ちます. ありがとうございました。アル