我在給定的下一行不斷收到此錯誤。但我無法理解如何解決它。請指導我有什麼問題。我知道這是與ARC的轉換指南,但我無法理解如何解決它。 return [self isUnique:ioValue forKey:@「serverId」];將間接指針隱式轉換爲指向'nsstring *'的objective-c指針不允許使用圓弧
- (BOOL)validateServerId:(id *)ioValue error:(NSError **)outError {
// DLog(@"%@",__strong ioValue);
// NSString *__strong a=ioValue;
return [self isUnique:ioValue forKey:@"serverId"];
}
- (BOOL)isUnique:(NSString *)value forKey:(NSString *)key{
if([key isEqualToString:@"serverId"])
{
NSFetchRequest * fetch = [[NSFetchRequest alloc] init];
[fetch setEntity:[NSEntityDescription entityForName:[self.entity name]
inManagedObjectContext:self.managedObjectContext]];
NSPredicate *predicate = [NSPredicate
predicateWithFormat:@"serverId = %@",value];
fetch.predicate = predicate;
NSError *error = nil;
NSUInteger count = [self.managedObjectContext
countForFetchRequest:fetch error:&error];
if (count > 1) {
// Produce error message...
// Failed validation:
return NO;
}
}
return YES;
}
當我根據你的方法改變它然後崩潰並給Exe_bad_access錯誤 –