English 中文(简体)
Reskit OM2 关系制图
原标题:Restkit OM2 relationship mapping

Im using Restkit OM2 to take in a json and map to objects on iphone. Im currently confused on how to structure the mappings and could do with some help.

下面是json案

    {
    -magic_verbs: [
    -{
    lemma: "work"
    position: 5
    score: "0.75"
    value: "working"
    }
    -{
    lemma: "head"
    position: 0
    score: "0.75"
    value: "heading"
    }
],
magic_advs: [
-{
lemma: "not"
position: 2
score: "0.6"
value: "not"
}
-{
lemma: "just"
position: 2
score: "0.6"
value: "just"
}
]
}

i 只需要从其中每个领域提取玉米和价值。 例如,饮料类含有饮料。

@interface Verbs : NSManagedObject {

}
@property (nonatomic,retain) NSString *lemma;
@property (nonatomic,retain) NSString *value;

@end

@implementation Verbs

@synthesize lemma,value;

@end

之后一读于json,并绘制地图,其代码如下:

objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://localhost:3000"];
        objectManager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"RKRelationshipMappingExample.sqlite"];

        [RKObjectManager setSharedManager:objectManager];

        RKObjectMappingProvider* provider = [[RKObjectMappingProvider new] autorelease];

        RKObjectMapping* verbMapping = [RKObjectMapping mappingForClass:[Verbs class]];
        [verbMapping mapKeyPath:@"lemma" toAttribute:@"lemma"];
        [verbMapping mapKeyPath:@"value" toAttribute:@"value"];
        [provider setMapping:verbMapping forKeyPath:@"magic_verbs"];
 [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/api/users/1/magic_words" objectMapping:verbMapping delegate:self];

我也为奇迹测绘做了同样的工作。 我还有一个称为“词”的类别,包含2个线索,以包含物体测绘数据。 但是,不能肯定如何落实这一点并将它们正确地联系起来。

@interface Words : NSObject {

    NSArray *_verbs;
    NSArray *_adjs;
}

@property (nonatomic, retain) NSArray *verbs,*adjs;
@end

感谢在这方面提供任何帮助和指导。 我研究了卡塔洛项目的例子,并且能够取得这一进展,但一直能够主宰这一概念,将其应用于我自己的杰森档案。

thanks

G

最佳回答

I suggest you to look at the new documentation of OM 2.0 that is in the Github page here if you haven t noticed yet. It clearly lays out on how to map your JSON to an object.

问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签