Re: NSString and NSMutableString
Re: NSString and NSMutableString
- Subject: Re: NSString and NSMutableString
- From: Michael Novak <email@hidden>
- Date: Sat, 14 Apr 2007 21:40:38 -0400
thanks greatly.... that worked perfectly.... I didn't think of
implementing it that way.....
many thanks all...
cheers,
mike
On Apr 14, 2007, at 9:33 PM, Andrew Farmer wrote:
On 14 Apr 07, at 18:19, Michael Novak wrote:
NSString *beginURL = @"http://www.google.com/search?hl=en&q=";
NSMutableString *searchQuery;
[searchQuery setString:[searchField stringValue]];
//catch the whitespace.
[searchQuery replaceOccurrencesOfString:@" " withString:@"+"
options:2 range:NSMakeRange(0, [searchQuery length])];
NSString *endURL = @"&btnG=Google+Search";
NSString *tempURL = [beginURL stringByAppendingString:searchQuery];
NSString *searchCall = [tempURL stringByAppendingString:endURL];
}
Nat Lanza probably has the crashes figured out, but there's a much
easier way of doing this:
NSString *searchCall = [NSString stringWithFormat:@"http://www.google.com/search?hl=en&q=
%@&btnG=Google+Search", [[searchField stringValue]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
(Code typed in Mail, may or may not work as advertised.)
This has the added benefit of encoding other characters (including
'+' and '&') correctly.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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