On 16/03/2009, at 5:20 PM, Peter Zegelin wrote:

OK - thanks everyone.

Just as I was about to wire things up in IB I realised that a subclass of NSTextField would be the best way. Turns out its a one liner in awakeFromNib.

- (void)awakeFromNib {
        
[self setStringValue:[[self stringValue] stringByReplacingOccurrencesOfString:@"<ApplicationName>" withString: [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]]];
}


In the same vein I have two other bits where I would like to automatically replace text. The first is my 'Warranty Panel'. I am currently loading it into an NSTextView like so:

[warrantyTextField readRTFDFromFile:[[NSBundle mainBundle] pathForResource:@"LicenseAgreement" ofType:@"rtf"]];

Because it is rtf, I understand it is much more involved to change all occurrences of <ApplicationName>. Does anyone know of an example how this is done? I found a few things like OmniAppkit that have a Find and Replace Panel but they seem way too complicated for this.



The second area is some menus under the application menu - specifically About... Hide and Quit. The top level Menu seems to reflect the application name but the rest just show About NewApplication etc. Would the best way to change these automatically be to:

wire up the first menu to my app delegate
get all the items with - (NSArray *)itemArray on awakeFromNib
iterate over all items in this array replacing the string like with my NSTextField subclass above?

Thanks!

Peter



I have some text labels in a registration dialog that contain the application name eg

"xxx Demonstration"
"Thank you for purchasing xxx"

and so on.

I would like this registration dialog to be general enough that I can use it in multiple applications. Is there a simple way to replace the xxx with the actual application name at runtime? At the moment I'm thinking I'll have to wire every label up to my registration controller and do it in awakeFromNib, but I was hoping for something easier.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to