Search code examples
cocoaswiftplaceholdercocoa-bindingsnstextfield

Swift string and cocoa bindings: placeholder string is not displayed


I have a dynamic var someString: String? = nil attribute in my class bound to an UI text field. The text field is configured to display a placeholder string when someString is empty (nil). But when I run the application the placeholder string does not show up even though someString is explicitly set to nil. I can remember the same window backed up with Objective-C code instead of Swift worked as expected and the text field shown the placeholder when the string was empty, but I cannot check it now to be sure. Anyway, is this a bug in Swift, or am I doing something wrong?


Solution

  • I've just found that there is "Null Placeholder" option in the Value binding configuration. That seems to override "Placeholder" setting in the Attributes inspector. So the question is closed.