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?

2
  • 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. Commented Aug 21, 2013 at 23:26
  • see my answer in 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. Commented Jan 8, 2014 at 13:27

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.