I am making an iBeacon based app, but when the user adds a new beacon and pushes save, the screen takes a second to load back to the main viewController. If the user presses save more than once, it makes it so that the beacon is added more than once. Is there a way to deactivate a button after it is touched to avoid this problem?
- (IBAction)saveTag:(id)sender
{
PFObject *newTag = [PFObject objectWithClassName:@"Tag"];
newTag[@"Name"] = self.tagName.text;
newTag[@"UUID"] = self.selectedBeacon.proximityUUID.UUIDString;
newTag[@"Major"] = self.selectedBeacon.major;
newTag[@"Minor"] = self.selectedBeacon.minor;
if ([self.tagName.text isEqualToString:@""]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Artemis" message:@"Cannot save tag without name" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
} else {
PFQuery *query = [PFQuery queryWithClassName:@"Tag"];
[query whereKey:(@"UUID") equalTo:self.selectedBeacon.proximityUUID.UUIDString];
[query whereKey:(@"Major") equalTo:self.selectedBeacon.major];
[query whereKey:(@"Minor") equalTo:self.selectedBeacon.minor];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(@"No errors found!");
}