If you're asking what I think you're asking, and by "activated" you mean "has been touched"/"has been selected", you're doing things backwards. Instead of checking whether the button has been selected within your queryForAllPostsNearLocation
method, have your button trigger the necessary query. In the following example, I've made button1
and button2
correspond to the UIButtons and I've replaced NSString *button1
with NSString *buttonText
just to make things a bit clearer.
- (IBAction)buttonSelected:(id)sender {
NSString *buttonText;
if (sender == button1)
buttonText = @"Today";
else
buttonText = @"Tomorrow";
PFQuery *query = [PFQuery queryWithClassName:buttonText];
}
Edit: In order to complete your desired query in this case, you can either (1) store currentLocation and nearbyDistance as class variables then access them within buttonSelected
in order to complete the query there or (2) you can fetch the currentLocation
and nearbyDistance
values within buttonSelected
then call a method like
// Modified to now include the button's text as an argument
-(void)queryForAllPostsNearLocation:(CLLocation *)currentLocation withNearbyDistance:(CLLocationAccuracy)nearbyDistance withButtonText(NSString*)buttonText
from within buttonSelected
, then perform the query from there.