How to fix "nsurlconnection finished with error - code 1100 " error for UIWebView in IOS? - objective-c

I am working on an existing project where UIWebview is used to load html string to load js files for loading contents downloaded from our server.Currently UIWebview is not able to load the contents in IOS which is perfectly loading in Android.
I have tried to switch to WKWebView but still no luck.
self.webContentView.delegate = self;
NSString* html = [player getHTMLString];
NSString* baseURL = [player getBaseURLPath];
[self.pageLoadingActivity startAnimating];
[self.webContentView loadHTMLString:html baseURL: [NSURL URLWithString: baseURL]];
EDIT------
After debugging sometime I found I was getting two 1100 error.
It seemed like two file were missing or app was not able to read them.
Now whenever I am hitting shouldStartLoadWithRequest with
request
URL:
file:///Users/ealpha4tech/Library/Developer/CoreSimulator/Devices/2CA71983-9996-44D6-944F-34E3EAFAE96D/data/Containers/Data/Application/6A19ABBA-CB68-4EE4-AC02-6AD3CB8A5A68/Documents/icplayer/icplayer/D2D6AFFF93CB2CFCB1640484F5429D89.cache.html
I am getting 1100 error.(the above file is present though)

So as a guess, I would say [player getHTMLString] is the problem.
NSURLErrorFileDoesNotExist: The specified file doesn’t exist.
This is a local file error.
I'm guessing that -getHTMLString is trying to load a file out of the app, but that file is not being included in the app.
I could help more if you provide 2 things.
Provide the source for -getHTMLString
Use NSLog() to print value of [player getBaseURLPath].
UPDATE
In looking at your output, I noticed …ments/icplayer/icplayer/D2D6A…. I think the proper path should only have one icplayer not two. Look to see if it's getting repeated somehow.

Related

Trouble uploading and downloading files from a WKWebView

Right now I am developing a macOS WebApp, this includes a WKWebview.
However, when I want to upload or download a file, it doesn't work. When I click, nothing happens! Like, nothing. I click on for example on “choose file” or any other upload button, and the window that should appear to select a file or directory doesn’t show up.
I have been struggling all day long, checking stackoverflow and many other resources and I found many posts related to my problem, but they are all out-dated.
My code is really simple;
- (void)viewDidLoad {
[super viewDidLoad];
// Load the url into the webview
NSURL *url = [NSURL URLWithString:#"https://www.my-website-url.com"];
[self.myView loadRequest:[NSURLRequest requestWithURL:url]];
}
So basically all I want is that I can download and upload files to and from my WKWebView.
It is NOT a duplicate question because I still don't get how to implement the code that Willeke is referring to in the comments.

dispatch_once in ShareKit causing crash

I was using ShareKit for a p long time, without downloading last updates from its repository.
Now i need some of its new features, so i've pulled all last commits and tried to run my app with new ShareKit without making any changes to my code (except some small changes in includes).
App compiles without errors but when i try to execute usual Facebook sharing code - it crashes without any useful error description.
old code i want to get to work
NSURL *url = [NSURL URLWithString:[NSString stringWithUTF8String:sk::game_services::get_app_store_url()]];
SHKItem *item = [SHKItem URL:url title:[NSString stringWithUTF8String:message] contentType:SHKURLContentTypeWebpage];
[SHKFacebook shareItem:item];
and according to updated ShareKit demo app and its documentation - this code should still work.
but it doesn't
it horribly crashes in currentIndicator method of SHKActivityIndicator inside macro DEFINE_SHARED_INSTANCE_USING_BLOCK that contains dispatch_once call.
debugger just says "SIGABRT" and thats all.
i don't know what to do.

Catching errors with setMainFrameURL in a Webview

I am using the following code to populate a webView in my Mac app...
NSURL *url = [NSURL URLWithString:#"https://joeworkman.net"];
[self setMainFrameURL:[url absoluteString]];
I would like to be able to capture when there are errors loading this URL and then instead load a local HTML file stored within my app. This way the users gets presented with a presentable error instead of an ugly 500 server error (if that was the case). Not to mention that most users would not know what that meant anyhow.

Getting null back from XML, but only on wi-fi only devices

I have an app that incorporates weather...data that I receive from Google's weather API. I'm busting my brain trying to figure out a problem that I'm having and I've been unsuccessful so I figured it was time to ask around on here.
Here is my code:
query = [[NSString stringWithFormat:#"%#",query] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(#"query: %#",query);
// SET GOOGLE WEATHER XML LOCATION
CXMLDocument *parse = [[CXMLDocument alloc]initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://www.google.com/ig/api?weather=%#", query]]options:0 error:nil];
NSLog(#"URL: %#", parse);
The query variable holds my reverse geocoder location (e.g. Chicago,IL) for which I append it to the Google URL to get the XML back.
As you can see I'm logging out both the query and the parse variables. I can see that I'm getting a legit query location for my current location when the code is executed, but by the time I log the parse variable I get nothing. The parse logging shows null...nothing was returned from Google. I can see that the URL is correct and I can even go to my browser and get the data I need by using the same logged link.
Interestingly enough...it works perfectly in the simulator and it also works just fine on my iPhone running 5.1.1. I do have iOS6b4 installed on my iPad which is giving the issue, but since I'm not using any new code that was introduced in iOS6 it shouldn't cause any issues here.
Any ideas as to why the XML parsing refuses to work on a wi-fi only iPad?
BTW, before anyone tells me to start using NSXMLParser instead of TouchXML...I do have a test version that runs NSXMLParser instead and I'm getting the same issue there as well. I'm at a loss.
I finally figured this out...it actually had to do with the locationManager.
I had the following code:
if ([locationManager respondsToSelector:#selector(startMonitoringSignificantLocationChanges)]) {
[locationManager startMonitoringSignificantLocationChanges]; }
else {
[locationManager startUpdatingLocation]; }
Getting rid of the if/else statement and just going with the following resolved it:
[locationManager startUpdatingLocation];

UIWebView loading errors

Whenever I load a page in a UIWebView i get this error in the console
ImageIO: <ERROR> _CGImagePluginInitGIFmalformed GIF file (1005 x 767)
It's logged several times, but doesn't seem to effect anything as the page loads as expected.
Here's the code that I'm using to load the page:
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[webView setDelegate:self];
Any ideas what this error means?
I think it's not to answer, as it comes from the deepest parts of CGImage. I have noticed this error myself several times in the simulator. As you have noticed, I can confirm that it doesn't do anything. Everything looks as expected.
You must check HTML file that you load.Post It! The snippet of code doesn't have error..