THX FOR THE HELP!
I changed the Viewdidload like that and it is working fine for me now! Iam Fetching the location and took a predicate to synchronize the checks and the state of the button
- (void)viewDidLoad
{
[super viewDidLoad];
app = (AppDelegate *) [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [app managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Standort" inManagedObjectContext:context];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ortcheck CONTAINS YES"];
[request setPredicate:predicate];
[request setEntity:entity];
NSError *error = nil;
NSArray *events = [context executeFetchRequest:request error:&error];
int i = events.count;
if (i == 0) {
myWeiter = [[UIBarButtonItem alloc] initWithTitle:@"Weiter" style:UIBarButtonItemStyleBordered target:self action:@selector(nextPressed:)];
self.navigationItem.rightBarButtonItem = myWeiter;
self.navigationItem.rightBarButtonItem.enabled = NO;
}
else {
myWeiter = [[UIBarButtonItem alloc] initWithTitle:@"Weiter" style:UIBarButtonItemStyleBordered target:self action:@selector(nextPressed:)];
self.navigationItem.rightBarButtonItem = myWeiter;
self.navigationItem.rightBarButtonItem.enabled = YES;
}