• 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: Michael Tsai <email@hidden>
  • Date: Tue, 9 Sep 2003 20:48:44 -0400

On Tuesday, September 9, 2003, at 07:53 PM, Chris Garaffa wrote:

NSMutableString *siteSearchSyntax = [[NSUserDefaults standardUserDefaults] objectForKey:selectedItem];
NSRange whereFound = [siteSearchSyntax rangeOfString: @"<$sbSearchTerm$>"];
[siteSearchSyntax replaceOccurrencesOfString: @"<$sbSearchTerm$>" withString: [searchText stringValue] options: NSLiteralSearch range: whereFound];
Seems to work, with the exception of the last line. When I run the code, I find that selectedItem is valid (by placing an NSLog after the first line) and that siteSearchSyntax is valid (by placing an NSLog after the second line), and that [searchText stringValue] is valid, but on the fourth line, I get the error in my log that the selector is not recognized.

NSUserDefaults is returning an immutable NSString, which doesn't have the replace method. So you'll need to make a -mutableCopy or something.

--Michael
_______________________________________________
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: NSOpenPanel and the New Folder button
  • Next by Date: Re: replaceOccurrencesOfString not recognized?
  • Previous by thread: NSOpenPanel and the New Folder button
  • Next by thread: Re: replaceOccurrencesOfString not recognized?
  • Index(es):
    • Date
    • Thread