views:

169

answers:

1

Hello,

another issue where I seem to have found an solution for ObjC but not MonoTouch.

I want a NSUrl from an URL (as string).

The string may contain whitespace and backslashes.

Why is NSUrl returning null for such string, even though these are valid urls in a browser?

For example: NSUrl foo = NSUrl.FromString(@"http://google.com/search?\query");

foo == null

Any suggestions?

+1  A: 

You probably need to process the string first with

stringByAddingPercentEscapesUsingEncoding: 

... so that it can be processed a valid URL.

TechZen