https://github.com/queeniecplusplus/ios_back_7
post http data to remote server
https://github.com/queeniecplusplus/ios_back_7
ios11 ios14 post postman swift4 swift5 urlsession urlsessiondatatask xcode11 xcode12
Last synced: 2 months ago
JSON representation
post http data to remote server
- Host: GitHub
- URL: https://github.com/queeniecplusplus/ios_back_7
- Owner: QueenieCplusplus
- Created: 2021-01-28T01:44:52.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-28T01:56:15.000Z (over 4 years ago)
- Last Synced: 2025-03-13T13:13:46.898Z (2 months ago)
- Topics: ios11, ios14, post, postman, swift4, swift5, urlsession, urlsessiondatatask, xcode11, xcode12
- Language: Swift
- Homepage: https://github.com/QueenieCplusplus/QuickGoThru/blob/master/README.md#apple-ios-swift-溫故愛鳳---計畫復甦
- Size: 466 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# iOS_Back_7
post http data to remote server using URLSessionDataTask1. code.
//
// ViewController.swift
// KatesPostmanApp
//
// Created by KatesAndroid on 2021/1/28 AM 9: 30
//
// wanna post url like "http://katesapp2019/ios.php?name=katespostmanapp&date=20210128"// using URLSession
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()// TODO: URL
let url = URL(string: "http://katesapp2019/ios.php")
var req = URLRequest(url: url!, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 30
)// TODO: Request Data
req.httpMethod = "POST"
req.httpBody = "name=katespostmanapp&date=20210128".data(using: .utf8)// TODO: URLSession and its DownloadTask
let config = URLSessionConfiguration.default
let ss = URLSession(configuration: config)
_ = ss.dataTask(with: req){
(data, res, err) in
if let data = data {
let htmlResData = String(data: data, encoding: .utf8)
print(htmlResData!)
}}
}
}
2. iOS' hot key.
dot to shall default param for augment.
3. setup for Timeout Interval.
