Take the 2-minute tour ×  I have a situation where troops can
attack buildings. Each troop keeps a pointer to its target.
@property (nonatomic, weak) Building *target;  In an update
loop, the troops periodically cause damage to their target.  if
(_target)       if (/*enough time has passed since last attack,
attack again*/)         [_target attack];         if
(_target.health <= 0)             [_target
removeFromParentAndCleanup:YES];   //Cocos2d             _target
= nil; else /* Find new target */   The problem is:    • troop1
deals the blow that fells building1 and moves on to building2
• troop2 was attacking building1 but waits until its next attack
to determine that building1 is now nil.  I realise the problem
is that troop2's pointer has not been set to nil and instead I
should be checking that the value of the pointer is nil.  I
tried using if (*_target) but was met with the message
Statement requires expression of scalar type  If there a way to
achieve this kind of comparison in Objective-C? What