2013-08-21 84 views
0

如何通过json post发送NSObject类?通过json post发送课程

例子:

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

在实现TestClass的另一个文件:

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

.....

如何测试对象发送?

+1

只是为了记录 - 它不是你试图序列化的类,而是类的_instance_。幸运的是,这简单得多。此外,正常的命名约定将具有以小写字母开头的属性(和方法)名称。 – Monolo

+0

在http://stackoverflow.com/a/20996601/730807中看到我的答案我正在使用这种方式,它工作得很好,它也会满足您的需求。希望这有助于您。 –

回答

1

由于@Carl指出,您必须输入convert it first to a JSON object,然后将其作为POST请求的参数发送。请注意,后端定义了您的数据如何发送请求。但这是最常见的做法。