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: Peter Zegelin <email@hidden>
- Date: Wed, 18 Mar 2009 15:37:29 +1100
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
<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
_______________________________________________
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