Thanks Michael,

        That works great. I changed the name of the variable as well:

[warrantyTextView readRTFDFromFile:[[NSBundle mainBundle] pathForResource:@"LicenseAgreement" ofType:@"rtf"]];
        
NSMutableString *warranty = [[warrantyTextView textStorage] mutableString]; [warranty replaceOccurrencesOfString:@"<ApplicationName>" withString: [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"] options:NSLiteralSearch range:NSMakeRange(0, [warranty length])];

Peter

On 18/03/2009, at 2:17 PM, Michael Ash wrote:

On Tue, Mar 17, 2009 at 10:41 PM, Peter Zegelin
<pe...@fracturedsoftware.com> wrote:
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.

It's actually quite straightforward. Assuming warrantyTextField is
actually an NSTextView (in which case you really ought to change the
name), [[warrantyTextField textStorage] mutableString] will give you
an instance of NSMutableString which reflects changes back to the text
view. Use your standard NSMutableString manipulations on that, and
that's all you have to do.

Mike
_______________________________________________

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/peter%40fracturedsoftware.com

This email sent to pe...@fracturedsoftware.com

_______________________________________________

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