Monday, November 28, 2022
HomeiOS DevelopmentCreating NSUrl throws exception

Creating NSUrl throws exception


I am writing an Xamarin.iOS app, but an answer in native iOS would suffice. I am displaying content from a url like this:

var url = new NSUrl(myUrl);
var request = new NSUrlRequest(url);
_myWkWebView.LoadRequest(request);

It works when myUrl is for a PDF. But when it's for a ppt, the first line (where I create NSUrl) throws this exception:

Could not initialize an instance of the type ‘Foundation.NSUrl': the
native ‘initWithString:' method returned nil. It is possible to ignore
this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to
false.

I tried the url on my Safari browser and it displays the ppt. What can I do to avoid this exception?

EDIT

Sample of myUrl that makes it crash:

https://d39izjanvtj4mt.cloudfront.net/022426393101/Attachments/Schedules/AWS%20Certified%20Developer%20Slides%20v4.6.pdf?X-Amz-Expires=900&x-amz-security-token=IQoJb3JpZ2luX2VjEB4aCXVzLWVhc3QtMSJHMEUCIEcbt5kHkEPnO1S7icqQACN1FZGTtqdRmqdRZ%2BR1ebdjAiEAi9B1is0pf6U6%2BTRdToMyBIz74Ad9eB%2BbUrmt15iw%2BLYqpwQIp%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARACGgw3MTM3OTIxMTY2NjAiDA6Ylf%2FWXMrW4U6qiSr7A7cSKfBsKMizBQ7P76LK1LjcFcrmKytlE6onaU6%2F6rpJNQ676q7Uw%2BSa0tDHzStdPq%2BF3koj6PBIKTyWRSoY7Jhs3%2BYUkvL8L%2Bm7lyW91Np969N5h4Or%2BUmBW2tNkpdWNB4xPv3hmPxrhW8QPUV8KrhXWW7IjKNnGrvTm8rXf3gFsPnEZoWl51VLBKLpvnK%2BllzPUVUAwEyHB23v0PIPPx5dXRl%2F2MwT1W3dapz6SatDd1ihZG4XG5niGmt6Z9FxMA5ROLS2ran07X4Tj3YwjY0qAIcaLxaua0doNHCMNLtls54bCS915PosaV4eP5StC7I5TtOmOCaToegS4xvRlXTJ2OZIc8peUDwElncCM8uArGORE0QHeE8qSsYC16TtgTSIUgdDZQzojsFkQS%2FhTXuu9%2BRUTHzwYjbJOOrvjSM1b9MAbdVaRurp5hXvB4134D5Ne1mb3yMCKiFNXqK%2FbAaBDwPnQSXha7H9FtcK%2BJeBeB95duRhFz0RzCPCRWaeGDV2ERoAceK5XmYjhAEDsHzNCUSwQjpck7TXEqmVlhLU426fCyYkasZBXvAGgFvbL3lq3mf4Q8ZrSFUJ7br3oweIwg143YfzJj8E%2BWD5LNMYWDud%2F7Pv%2FZozxKytnc%2Fk2HOy6Pnq56xnwR5IYXApZ3%2F5hjMlbaa%2F4FK%2BazCi97WLBjqFApl6IsCwdMn7tEbLxCmtXOGv%2FnV92ZqNp2lkNTcvIZ0oklOg1BM187gLrgwDQSUq0%2F1Ivry2We2sYKqyCGi%2BoZ8dx9KQ7aRl692EgI9MAv73PIJI0GSdykuDHy7lyJGzsdFBfEnfzgj6XlRlVLKg3Nq2eOf1cdKfR7NBiYXyy0Ii9UZn94pd0CrQqKlURhUNCB8vjAB79OBKrtp5VuYS2cZmzFYFrxnzfRljsUkM53Xn6dWtWvg95LvcDXMbujSOL%2Fxy8%2BCVMt0icDk22OW04xrtvpyOpZrsn%2Bd8iAGYc21ITwYxp%2BiNHtvlVUkBs7zQzBbYT79M82XaGbj4evFUv63esAzynQ%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA2MMKTK62LMOZRQJZ/20211018/us-east-1/s3/aws4_request&X-Amz-Date=20211018T135101Z&X-Amz-SignedHeaders=host;x-amz-security-token&X-Amz-Signature=fbbb9c3fd6a949d6d3aec871348174c9807493ddee9bf7aa0072412d92fb2b1e

(this url expired so you won't see the ppt when you try to open it in your browser)

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments