objective c - RestKit - Automatic entity mapping -


i'm trying use restkit perform automatic mapping of given entity class name, without having define fields manually.

example, imagine managed object called product fields: id, name, type. entity on default store.

i need list of products url http://machin.net/products

rkentitymapping *map = [rkentitymapping mappingforentityforname:@"product"     inmanagedobjectstore:[rkmanagedobjectstore defaultstore]]; 

question 1 defaultstore not satisfying required store, don't know how specify it.

[map addattributemappingsfromdictionary:@{     @"id": @"id",     @"name": @"name",     @"type": @"type", }]; 

question 2 can see, i'm using fields , same on source & destination, didn't find way tell restkit use fields of given class.

for 1. need configure restkit / core data stack

    nsmanagedobjectmodel *managedobjectmodel = [nsmanagedobjectmodel mergedmodelfrombundles:nil];     rkmanagedobjectstore *managedobjectstore = [[rkmanagedobjectstore alloc] initwithmanagedobjectmodel:managedobjectmodel];      self.managedobjectstore = managedobjectstore;      [rkmanagedobjectstore setdefaultstore:managedobjectstore];      // complete core data stack setup     [managedobjectstore createpersistentstorecoordinator]; 

for 2. can use

[map addattributemappingsfromarray:@[ @"id", @"name", @"type", ]; 

technically use introspection on entity you'd write lot more code.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -