dchohfi / KeyValueObjectMapping

Automatic KeyValue Object Mapping for Objective-C, parse JSON/plist/Dictionary automatically
http://dchohfi.com/
MIT License
600 stars 90 forks source link

How to create a real one-to-many relationship? #28

Closed MartinMoizard closed 11 years ago

MartinMoizard commented 11 years ago

Hello,

I'm new to KeyValueObjectMapping so my question might sound easy: how to create the two relationships of a one-to-many relationship?

For instance, let's take the example of the User that has many tweets:

I figured out to do 1) very easily but can't find a way to do the 2) link. Is there any way to do that?

Cheers, Martin

MartinMoizard commented 11 years ago

My teammate viteinfinite modified the code in order to create the relationship ( https://github.com/viteinfinite/KeyValueObjectMapping/commit/1e8d48af4c2743effe45a18187d6c69345899894 ):

DCCustomInitializeBlock customBlock = ^(__weak Class classOfObjectToGenerate, NSDictionary *values, id parentObject) {
    id object = [[classOfObjectToGenerate alloc] init];
    object.parentTweet = parentObject;
    return object;
};