• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: replaceOccurrencesOfString not recognized?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
References: 
 >replaceOccurrencesOfString not recognized? (From: Chris Garaffa <email@hidden>)

  • Prev by Date: Re: replaceOccurrencesOfString not recognized?
  • Next by Date: Re: "Borrowing" images from applications with *.rsrc files
  • Previous by thread: Re: replaceOccurrencesOfString not recognized?
  • Next by thread: RE: replaceOccurrencesOfString not recognized?
  • Index(es):
    • Date
    • Thread