teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ソースコードの修正

2016/08/11 20:25

投稿

syale
syale

スコア8

title CHANGED
File without changes
body CHANGED
@@ -25,38 +25,6 @@
25
25
  do {
26
26
  let jsonData = try JSONSerialization.data(withJSONObject: strData!, options: .prettyPrinted)
27
27
 
28
- let request = NSMutableURLRequest(url: NSURL(string: "http://localhost/test.php")! as URL)
29
- request.httpMethod = "POST"
30
-
31
- request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
32
- request.httpBody = jsonData
33
- request.addValue("application/json", forHTTPHeaderField: "Content-Type")
34
- request.addValue("application/json", forHTTPHeaderField: "Accept")
35
-
36
- let task = URLSession.shared.dataTask(with: request as URLRequest){ data, response, error in
37
- if error != nil{
38
- print("Error 55 -> \(error)")
39
- return
40
- }
41
-
42
- do {
28
+ ・・・
43
- let result = try JSONSerialization.jsonObject(with: data!)
44
-
45
- print("Result 34 -> \(result)")
46
-
47
- } catch {
48
- print("Error 43-> \(error)")
49
- }
50
- }
51
- task.resume()
52
- }
53
- catch {
54
- print(error)
55
- }
56
29
 
57
- ```
30
+ ```
58
-
59
- ###補足情報
60
- Xcode8.0beta2
61
- PHP5.5.36
62
- MAMP