1

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

enter image description here

is it not the right way to set boolean value?

3 Answers 3

3

It should be @property (nonatomic, assign) BOOL debit; NOT @property (nonatomic, assign) BOOL *debit;.

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

Comments

1

You wrote BOOL *debit;, which means pointer to a BOOL

Change it to BOOL debit;

Comments

1

@property (nonatomic, assign) BOOL *debit; should not have an asterisk (*)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.