Reputation: 1120
So I have an NSObject which implements NSCoding. In my decoder method it needs to retrieve a BOOL that belongs to the class among other properties.
-(id)initWithCoder:(NSCoder *)decoder {
self = [super init];
if (self) {
[self setRandomObject:[decoder decodeObjectForKey:@"randomObjectKey"]];
[self setMyBool:[decoder decodeBoolForKey:@"myBoolKey"]];
}
return self;
}
This however throws the following warning on the line with [self setMyBool ...
(Yellow warning, still runnable).
Incompatible integer to pointer conversion sending 'BOOL' (aka 'signed char') to parameter of type 'BOOL *' (aka 'signed char *')
I don't understand why it is trying to send a pointer of a bool to a bool. If anyone knows how this can be fixed please let me know! Thanks a ton.
Also, it's very late right now, and me being exhausted, I may have just missed something simple so please bear with me.
Upvotes: 0
Views: 512
Reputation: 1120
So it appears I accidentally declared the property as a BOOL *
instead of a BOOL
. I changed it and everything works now. After reading the comments and answers I decided that the method was correct, then looked at the declaration of the property. Thank you very much, coding late at night is harder than I thought.
Upvotes: 0
Reputation: 33349
Does your method look like this?
- (void)setMyBool:(BOOL *)value
or:
@property BOOL *myBool;
Because it should be:
- (void)setMyBool:(BOOL)value
or:
@property BOOL myBool;
Upvotes: 2