Reputation: 17169
In my iPhone app I have a BOOL named isAddressCell
. This works fine, and I can call this without an issue:
[cell setIsAddressCell:YES];
However, I have looked around at creating a custom setter method and had no luck creating one and it appears my BOOL is never actually set. I have below the setter method code I have tried which fails.
All I want to do it when setIsAddressCell
is called, depending on the value, certain other actions will occur.
Current, non-functional setter method:
@property (nonatomic, assign, setter = setIsAddressCell:) BOOL isAddressCell;
-(void)setIsAddressCell:(BOOL)addressCell
{
if (addressCell)
{
//Do stuff...
}
else
{
//Do different stuff...
}
}
Upvotes: 0
Views: 1263
Reputation: 17169
I was being a dummy. Tell if I am still doing it wrong, but I should have it like this:
-(void)setIsAddressCell:(BOOL)addressCell
{
if (addressCell)
{
//Do stuff...
}
else
{
//Do different stuff...
}
isAddressCell = addressCell;
}
isAddressCell = addressCell;
That bit is the key, I stupidly didn't set the value at the end of my manual setter method. Doh.
Upvotes: 1