感谢您的帮助!
我像那样更改了 Viewdidload,现在它对我来说工作正常!我正在获取位置并使用谓词来同步检查和按钮的状态
- (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;
}