How can I programmatically know if a NSTextField is currently displaying a placeholder ?
In other terms, if a placeholder has been assigned to it... ?
thanks
Use the method:
- (NSString *)placeholderString
Returns the cell's plain text placeholder string.
This method is declared in NSTextFieldCell and The NSTextField
class uses the NSTextFieldCell
class to implement its user interface:
All of the methods declared by this class are also declared by the NSTextField class, which uses NSTextFieldCell objects to draw and edit text. These NSTextField cover methods call the corresponding NSTextFieldCell methods.
Example (the placeholder must be access via the textfield's cell):
NSTextField *textField = [[NSTextField alloc] init];
NSString *placeHolderString = [[textField cell] placeholderString];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.