다른 대답은 더 이상 내가 수정하는 약간 다른 솔루션을 함께 왔어요 그래서 작동하는 것 같다없는 기존의 주어진 널 자리 문자열을 사용하는 바인딩 : 내보기 컨트롤러에이 방법을
:
를
- (void)awakeFromNib {
// Hacky hack hack: Xcode is stupid and doesn't localize the null placeholders so we have to do it.
[self rebind:@"contentValues" of:self.fooPopup withNullPlaceholder:NSLocalizedString(@"No foos available", @"foo popup null placeholder")];
[self rebind:@"contentValues" of:self.barPopup withNullPlaceholder:NSLocalizedString(@"No bars available", @"bar popup null placeholder")];
}
localiz을 :
- (void)rebind:(NSString *)binding of:(id)object withNullPlaceholder:(NSString *)nullPlaceholder {
// Possibly a bad idea, but Xcode doesn't localize the null placeholder so we have do it manually.
NSDictionary *bindingInfo = [object infoForBinding:binding];
id bindObject = bindingInfo[NSObservedObjectKey];
NSString *keyPath = bindingInfo[NSObservedKeyPathKey];
NSMutableDictionary *options = [bindingInfo[NSOptionsKey] mutableCopy];
options[NSNullPlaceholderBindingOption] = nullPlaceholder;
[object unbind:binding];
[object bind:binding toObject:bindObject withKeyPath:keyPath options:options];
}
나는 지역화 된 문자열을 전달 필요한 모든 바인딩에 대한 awakeFromNib
이 전화 ed 문자열은 보통 Localizable.strings
파일의 일부로 지역화됩니다.
매력처럼 작동합니다. 감사합니다. 관심있는 모든 사람들을 위해 나는 선택된 값에 대한 값 변환자를 주변에 몰아 넣었으며, 메뉴의 마지막 옵션으로 추가된다는 점을 제외하고는 잘 동작한다. 반면 null 자리 표시자는 메뉴 상단에 설정된다. – Monolo
Null 값은 다른 편집 가능/사용 가능 동작을 초래하기 때문에 값 변환기를 사용하면 편집 가능 및 사용 가능 바인딩을 유지해야합니다. 두 옵션을 모두 제공 할 생각 이었지만이 방법이 훨씬 쉬워 보였습니다. – paulmelnikow
이것은 나를 위해 작동하지 않았다. 내 NSObjectController' 하위 클래스 및 메서드가 호출되지 않았습니다. – mattsven