NSURL with query string
-
Greetings,
For my application, I need to form a NSURL, which looks something like this:
http://www.google.com/search?hl=en&q=test
I have the following code:
NSURL *url = [NSURL URLWithString: baseUrl]; //where baseUrl is
http://www.google.com/search
However Im not able to find a optimized way to append the query
strings "hl" and "q". Any help is apprecaited. Thanks.
- Sandeep -
On 2008 Apr, 12, at 12:24, C Sandeep wrote:> However Im not able to find a optimized way to append the query
> strings "hl" and "q". Any help is apprecaited. Thanks.
I've done this many times, by simply combining the query into what you
call your baseURL using -[NSString stringWithFormat:]. I suppose it's
not elegant, but once the sausage gets into the TCP pipe, no one cares
how you made it.
As far as being "optimized", don't worry about it. The slowest Mac
can probably easily spit out thousands of these before Google responds
to the first one. -
On Apr 12, 2008, at 3:24 PM, C Sandeep wrote:> Greetings,
> For my application, I need to form a NSURL, which looks something
> like this:
> http://www.google.com/search?hl=en&q=test
>
> I have the following code:
> NSURL *url = [NSURL URLWithString: baseUrl]; //where baseUrl is
> http://www.google.com/search
>
> However Im not able to find a optimized way to append the query
> strings "hl" and "q". Any help is apprecaited. Thanks.
if you're asking if NSURL has a way of specifying (and encoding)
parameters for a query, the answer is no.
This is definitely something worth filing a bug about.
I'd also be surprised if someone on the list hasn't solved this and
created a category on NSURL to implement this. Anyone able to offer
that type of solution?


