Setting a static window Title that precedes a variable Title
I apologize for the confusing post Title. This is what I mean:
Lets say I have an action that displays window ti开发者_C百科tle text. It's a non doc based app.
[window setTitle:@"Completed"];
I want to add a static title to this returned string. Something like "Status." So when the action is triggered, the window title reads:
Status:Completed, or Status:Incomplete, etc.
So "Status" always preceeds the variable string. The variable string reflects a string that exists based on another action in the app. So I cannot achieve the results that I am looking for by simply doing:
[window setTitle:@"Status:Completed"]; etc, etc.
How can I do this?
thanks
Paul
Either subclass NSWindow or add a category to NSWindow like -setStatus:
that calls -setTitle:
with your desired prefix.
If none of this is workable, you can watch NSWindowDidUpdateNotification
and update the title if it lacks your prefix. This notification is documented to be sent before the window is drawn, so you shouldn't have any flickering. Alternately you could use bindings to watch -title
and do the same thing. Bindings would possibly have a little better performance, since you'd only call your code when the title actually changes.
精彩评论