ios - How to import array attribute with MagicalRecord into CoreData -
i importing json objects have many array attributes such images:
"images": [ "model1.jpg", "model2.jpg" ], "models": [] "one model", "another model", "third model" ] currently do:
[exampleobject mr_importfromarray:objectarrayfromjson]; but these arrays break auto import since can't auto fit nsarray nsdata (the binary when setting model in xcode).
is there anyway modify model class files (like custom setters/getters) magicalrecord can import array , store in entitys´ attribute , when retrieve nsarray in return?
i solved myself after research , want share whoever might stuck same problem.
my problem wanted save nsarray entity attribute of type nsdata. able magicalrecord needed implement method in nsmanagedobject m-file this:
- (bool) importimages: (id) array { nsdata *imagesdata = [nskeyedarchiver archiveddatawithrootobject:array]; self.images = imagesdata; return yes; } so import<;attribute-name without ;> method must called.
edit: according this page return yes if code process data. return no if want magicalimport continue processing attribute , use default import routines.
Comments
Post a Comment