Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is GCDWebServer for?

I have a problem when loading the local web from WKWebView in iOS8. There are some suggestions that I should use GCDWebServer. I read through GCDWebServer, but not really understand what GCDWebServer is for on mobile application's side.

Could you give me any practical case of using this library? Sorry for my ignorance.

like image 406
chipbk10 Avatar asked Mar 30 '15 12:03

chipbk10


2 Answers

It's a webserver that you can run on your iOS device. Just like you would run a webserver on VPS or dedicated server providers.

This webserver that you would run and host from your iOS app will of course be available only in the network your iOS device is connected to.

This makes it useful for you to write client programs or scripts on other machines but connected to that network, to call your iOS app (running the GCDWebServer) to upload or download files that you so choose to store in your iOS app's sandboxes document directory for instance. Or as simple as viewing HTML or other data - plain text or json - served by GCDWebServer.

It had nothing to do with what WKWebView. WKWebView is a 'simplified WebKit browser client' that you can implement in your iOS app to view web pages served from other webserver hosts.

You can think of WKWebView as the complete opposite of GCDWebServer.

like image 52
Calvin Cheng Avatar answered Oct 27 '22 01:10

Calvin Cheng


We can use GCDWebServer has a network interceptor in ios. You can intercept any HTTP requests happening inside WKWebView. For example, you can use GCDWebServer to handle caching and parallel processing for your expensive API requests. You can immediately return some cached responses and later redirect the URL to the actual destination.

like image 27
Vinay Hosamane Avatar answered Oct 27 '22 01:10

Vinay Hosamane