Re: Automatically replacing part of text in a text label
Re: Automatically replacing part of text in a text label
- Subject: Re: Automatically replacing part of text in a text label
- From: Michael Ash <email@hidden>
- Date: Tue, 17 Mar 2009 23:17:06 -0400
On Tue, Mar 17, 2009 at 10:41 PM, Peter Zegelin
<email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden