#dataTaskWithURL
Explore tagged Tumblr posts
Video
youtube
Swift: Loading Images Asynchronously and storing with NSCache and NSURLCache
my review point is 9/10
https://youtu.be/BIgqHLTZ_a4?t=1m55sĀ Ā getting image from url ( NSURLSession.sharedSession().dataTaskWithURL )
https://youtu.be/BIgqHLTZ_a4?t=7m18sĀ Ā ź°ė°ģź° ė§ė¤ģ“ ģ¬ģ©ķė image caching example
https://youtu.be/BIgqHLTZ_a4?t=10m45sĀ Ā memory low warning hook ( didReceiveMemoryWarning )
https://youtu.be/BIgqHLTZ_a4?t=11m30sĀ Ā appleģģ ģ ź³µķė NSCache넼 ģ“ģ©ķ caching ģģ
https://youtu.be/BIgqHLTZ_a4?t=13m45sĀ Ā urlģģ
ģ źø°ė³ø cache źø°ė„ģ“ ģėė° ģ“ źø°ģ¤ģ¹ė„¼ ė³ź²½ķė ė°©ė² (Ā NSURLCache )
#ios#brian#facebook feed#facebook#NSCache#NSURLCache#image#dataTaskWithURL#NSURLSession#sharedSession#cache#memory#low memory#didReceiveMemoryWarning
0 notes
Text
Disable Apple Transport Security iOS Tutorial
Apple Transport Security(ATS) requires network requests to be sent over a secure connection. Apple Transport Security is enabled by default, so when it is still needed to make HTTP requests to an external source out of your control, ATS needs to be disabled. In this tutorial a request to a local server will be made and ATS will be disabled to make the connection. This tutorial is made with Xcode 10 and built for iOS 12.
Open Xcode and create a new Single View App.
For product name, use IOSDisableATSTutorial and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and choose Next.
In Mac OS X, the Python language including a web server module is installed by default.Ā Open a terminal and enter the following commands to start the web server
mkdir web cd web echo "testing Web Server" > index.html python http.server
The http.server listens at port 8000 by default. Test this connection by opening a new terminal to enter the following command
wget -qO- localhost:8000
This will give the output "testing Web Server" to indicate the Web Server is serving requests. While leaving the terminal open go back to the Xcode Project and navigate to the ViewController.swift file and add the following method.
func webRequest() { let url = NSURL(string: "http://localhost:8000") let task = NSURLSession.sharedSession().dataTaskWithURL(url!) { (data, response, error) in if let dataReturned = data { print(NSString(data: dataReturned, encoding: NSUTF8StringEncoding)!) } } task.resume() }
This method creates an HTTP GET requests at the specified URL and prints the result in the console.Ā Add the following line at the end of the viewDidLoad method
webRequest()
Build and Run the program. This will result in the following error in the console.
To avoid the error Apple Transport Security needs to be disabled. Go to the Info.plist. Right-click on Ā the Information Property List at the top of the file and choose Add Row. Select the Key "App Transport Security Settings" and choose Type Dictionary. Add another row inside the new key and select "Allow Arbitrary Loads". The type will be Boolean with a value of YES. The info.plist should now look like this.
Build and Run the project again. Now the web request will succeed.
You can download the source code of the IOSDisableATSTutorialĀ at the ioscreator repository on Github.
0 notes