0

How can a NSObject class be sent through json post?

Example:

@interface TestClass : NSObject
 @property (nonatomic,strong) NSString *Value1;
 @property (nonatomic,strong) NSString *Value2;
 @property (nonatomic,strong) NSString *Value1;
@end

In another file that implements the TestClass:

TestClass *test = [[TestClass alloc]init];
test.Value1 = @"First";
test.Value2 = @"Second";
test.Value3 = @"Third";

.....

How can the test object be sent?

cdhowie
  • 158,093
  • 24
  • 286
  • 300
Angie
  • 475
  • 2
  • 6
  • 20
  • 1
    Just for the record - it is not the class that you're trying to serialise, but an _instance_ of the class. Luckily, that is much simpler. Also, normal naming conventions would have property (and method) names beginning with lower case. – Monolo Aug 21 '13 at 23:26
  • see my answer in http://stackoverflow.com/a/20996601/730807 I am using that way and it works so well and it will suit your needs too.Hope this helps. – Durai Amuthan.H Jan 08 '14 at 13:27

1 Answers1

1

As @Carl points out you have to convert it first to a JSON object, and then send it as a parameter on your POST request. Be aware that the back-end defines how your data should be send for requests. But this is the most common way of doing it.

Community
  • 1
  • 1
CoderPug
  • 908
  • 9
  • 19