iphone - NSDictionary or NSKeyedArchiver -


in model portion, have data types properties property list data types. eventually, users sending each other these data items on network posting , reading server. question is, should using nscoding , nskeyedarchiver (as in second code block below, makes ugly xml imho) or should subclass nsdict can use dictionarywithcontentsoffile: , writetofile:atomically: pretty xml?

@interface word : nsobject <nscoding> @property (strong, nonatomic) nsstring *language; @property (strong, nonatomic) nsstring *name; @property (strong, nonatomic) nsdictionary *detail; @property (strong, nonatomic) nsstring *username; @property (strong, nonatomic) nsstring *userid; @property (strong, nonatomic) nsarray *files; - (void)copyfromtemporaryfiles:(nsarray *)temporaryfiles; // populates self.files @end 

and

@interface category : nsobject <nscoding> @property (strong, nonatomic) nsstring *name; @property (strong, nonatomic) nsdictionary *detail; @property (strong, nonatomic) nsdate *updated; @property (strong, nonatomic) nsarray *words; + (category *)categorywithname:(nsstring *)name; - (void)savewithname:(nsstring *)name; @end 

in opinion, neither of these options great practice sending data on network since file sizes relatively large compared other formats. instead, use json library transmit sort of structured data. if you're building ios 5+, can nsjsonserialization (reference here) simple, straightforward conversion (just pack ivars in dictionary , pass +datawithjsonobject:options:error, send data on network, , unpack +jsonobjectwithdata:options:error). otherwise, there's bunch of 3rd party and/or open source solutions out there. sbjson comes mind.

p.s. wary of subclassing nsdictionary. class represents class-cluster , has bunch of optimization going on background handle best use of memory, etc. can read subclassing notes on reference page find other means of adding functionality dictionaries.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -