Re: replaceOccurrencesOfString not recognized?
Re: replaceOccurrencesOfString not recognized?
- Subject: Re: replaceOccurrencesOfString not recognized?
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 9 Sep 2003 18:07:30 -0700
On Tuesday, September 9, 2003, at 04:53 PM, Chris Garaffa wrote:
I'm trying to replace a piece of an NSMutableString with another
string. The following code:
NSString *selectedItem = [[popupMenu selectedItem] title];
NSMutableString *siteSearchSyntax = [[NSUserDefaults
standardUserDefaults] objectForKey:selectedItem];
IIRC, NSUserDefaults returns immutable strings, so that won't work.
NSRange whereFound = [siteSearchSyntax rangeOfString:
@"<$sbSearchTerm$>"];
[siteSearchSyntax replaceOccurrencesOfString: @"<$sbSearchTerm$>"
withString: [searchText stringValue] options: NSLiteralSearch range:
whereFound];
The last line would return an error if NSUserDefaults returned an
immutable string.
Try replacing the second line with this:
NSMutableString *siteSearchSyntax = [NSMutableString
stringWithString:[[NSUserDefaults standardUserDefaults]
objectForKey:selectedItem]];
I think you'll have better luck with that...
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://seiryu.home.comcast.net/
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone." - Bjarne Stroustrup
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.