Consider this json
{
"amount": "60.81",
"category": "Utilities",
"debit": true,
"name": "Comcast",
"date": "Sat, 02 Aug 2014 14:36:46 -0000",
"uuid": "112c43eb-6e5e-4b4d-9079-6d896fa11b01"
}
I have a TransactionModel class which looks like
TransactionModel.h
@interface TransactionModel : NSObject
@property (nonatomic, strong) NSString *uuid;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *amount;
@property (nonatomic, strong) NSString *category;
@property (nonatomic, assign) BOOL *debit;
@property (nonatomic, strong) NSString *date;
- (TransactionModel *) initWithDictionary: (NSDictionary *) dictionary;
@end
and in TransactionalModel.m, I do the following
@implementation TransactionModel
- (TransactionModel *)initWithDictionary:(NSDictionary *)dictionary {
TransactionModel *transactionModel = [[TransactionModel alloc] init];
transactionModel.uuid = [dictionary valueForKey:@"uuid"];
transactionModel.name = [dictionary valueForKey:@"name"];
transactionModel.amount = [dictionary valueForKey:@"amount"];
transactionModel.debit = [[dictionary valueForKey:@"debit"] boolValue];
transactionModel.category = [dictionary valueForKey:@"category"];
transactionModel.date = [dictionary valueForKey:@"date"];
return transactionModel;
}
@end
I am using AppCode and it warns on line
transactionModel.debit = [[dictionary valueForKey:@"debit"] boolValue];
as
Taking pointer from integer without a cast
is it not the right way to set boolean value?