Hi all, i'm rather new to programming in cocoa but I've been working on learning the language quite diligently up until I hit this snag that I can't seem to circumvent/hack my way around, (not that I'd want to. I'd prefer to do it right!)
Where i stand, In IB i have a toolbar that has a button and what I'm trying to do is mimic the maps app. iI want to be able to press the button and then have my location pop up, while keeping the button selected, then when it's pressed again, deselect it and thus, remove the blue blip location from the map.
ideally, I would like to use the following code, but the if statement doesn't seem to want to work on the simulator (which i presume wouldn't change if i tried on the iphone.)
-(IBAction) showLocation: (id) sender { if([sender isSelected]) // this doesn't work!! { [sender setSelected:NO]; mapView.showsUserLocation = FALSE; } else { [sender setSelected:YES]; mapView.showsUserLocation = TRUE; } }
obviously if I get rid of the if statement, I know that i can show the location and set the selected as I liked, but I can't seem to "get" the selected property from the button... whats the right way of doing this??