我有一点 json 编码问题:
我需要使用 SBJSON 对对象格式 JSON 进行编码,然后再将其发送到 php 服务器 目前此示例代码有效:
NSArray *arrayData = [NSArray arrayWithObjects:
user.id == nil ? [NSNumber numberWithInt:-1] : user.id,
ProfessionField.text, NameField.text, RPPSField.text, RPPSField.text,
NameField.text, SurnameField.text, StreetField.text,
TownField.text, CpField.text, MailField.text,
PhoneField.text, FaxField.text, MobileField.text,
// [user.horaires JSONRepresentation],
nil];
NSArray *arrayKey = [NSArray arrayWithObjects:
@"id", @"spe", @"name", @"rpps", @"cip",
@"name", @"surname", @"rue",
@"ville", @"cp", @"mail",
@"tel", @"fax", @"port",
// @"horaires",
nil];
NSDictionary *dataBrut = [NSDictionary dictionaryWithObjects:arrayData forKeys:arrayKey];
NSDictionary *jsonDict = [NSDictionary dictionaryWithObject:dataBrut forKey:@"data"];
NSString *jsonRequest = [jsonDict JSONRepresentation];
问题是当我需要在该对象的 JSON 表示中发送“user.horaires”(此处为评论)应用程序崩溃时。
此对象是以下类的数组:
@interface Horaire : NSObject
{
BOOL morning;
}
@property (nonatomic, strong) NSNumber *id;
@property (nonatomic, strong) NSString *open;
@property (nonatomic, strong) NSString *close;
有人知道如何成功编码吗?