1

I created a custom class for contacts like

 *c.h*

 @interface Contact : NSObject

 @property NSString *c_id;
 @property NSString *c_name;
 @property NSString *phn_no;
 @property NSString *email_id;

 -(id) initWithCid: (NSString*) cid andCname: (NSString*) cnm andCphn:(NSString*) ph andCmail: (NSString*) mail;
 @end

I am storing them as array of dictionary to convert them to JSON data using NSJSONSerialzation

I want to know if there is any way that if I am going to create a array of contact objects, how do I convert them to JSON data??

Basically my question is how to serialize and deserialize array of objects to and from JSON data.

CodeChanger
  • 7,953
  • 5
  • 49
  • 80
user2017
  • 73
  • 7
  • 4
    You need to create Array of dictionary form array of custom objects and then use nsjsonserialzation to convert it to json data. – Nirav D Jan 27 '17 at 04:29
  • This content may be help you [SatakOverflow link][1] http://stackoverflow.com/questions/11932864/how-to-create-json-in-objective-c – R.A.Munna Jan 27 '17 at 05:30
  • You can traverse each dictionary from your array of dictionary and create Contact object during each iteration, assign appropriate values and add it to some mutable array. – Anoop Nyati Jan 27 '17 at 05:47

0 Answers0