@@ -27,15 +27,15 @@ class ResponseData
27
27
* @return json dictionary
28
28
*/
29
29
func json( error: NSErrorPointer = nil ) -> NSDictionary ? {
30
- let httpResponse = urlResponse as NSHTTPURLResponse
31
- if httpResponse. statusCode == 200 {
32
- let jsonData = NSJSONSerialization . JSONObjectWithData ( data, options: . AllowFragments, error: error) as NSDictionary
33
- return jsonData
30
+ if let httpResponse = urlResponse as? NSHTTPURLResponse {
31
+ if httpResponse. statusCode == 200 {
32
+ let jsonData = NSJSONSerialization . JSONObjectWithData ( data, options: . AllowFragments, error: error) as! NSDictionary
33
+ return jsonData
34
+ }
35
+ else if error != nil {
36
+ error. memory = NSError ( domain: " HTTP_ERROR_CODE " , code: httpResponse. statusCode, userInfo: nil )
37
+ }
34
38
}
35
- else if error != nil {
36
- error. memory = NSError ( domain: " HTTP_ERROR_CODE " , code: httpResponse. statusCode, userInfo: nil )
37
- }
38
-
39
39
return nil
40
40
}
41
41
@@ -45,14 +45,14 @@ class ResponseData
45
45
* @return UIImage
46
46
*/
47
47
func image( error: NSErrorPointer = nil ) -> UIImage ? {
48
- let httpResponse = urlResponse as NSHTTPURLResponse
49
- if httpResponse. statusCode == 200 && data. length > 0 {
50
- return UIImage ( data: data)
51
- }
52
- else if error != nil {
53
- error. memory = NSError ( domain: " HTTP_ERROR_CODE " , code: httpResponse. statusCode, userInfo: nil )
48
+ if let httpResponse = urlResponse as? NSHTTPURLResponse {
49
+ if httpResponse. statusCode == 200 && data. length > 0 {
50
+ return UIImage ( data: data)
51
+ }
52
+ else if error != nil {
53
+ error. memory = NSError ( domain: " HTTP_ERROR_CODE " , code: httpResponse. statusCode, userInfo: nil )
54
+ }
54
55
}
55
-
56
56
return nil
57
57
}
58
58
@@ -64,17 +64,17 @@ class ResponseData
64
64
* @return
65
65
*/
66
66
func parseXml( delegate: NSXMLParserDelegate , error: NSErrorPointer = nil ) -> Bool {
67
- let httpResponse = urlResponse as NSHTTPURLResponse
68
- if httpResponse. statusCode == 200 {
69
- let xmlParser = NSXMLParser ( data: data)
70
- xmlParser. delegate = delegate
71
- xmlParser. parse ( )
72
- return true
73
- }
74
- else if error != nil {
75
- error. memory = NSError ( domain: " HTTP_ERROR_CODE " , code: httpResponse. statusCode, userInfo: nil )
67
+ if let httpResponse = urlResponse as? NSHTTPURLResponse {
68
+ if httpResponse. statusCode == 200 {
69
+ let xmlParser = NSXMLParser ( data: data)
70
+ xmlParser. delegate = delegate
71
+ xmlParser. parse ( )
72
+ return true
73
+ }
74
+ else if error != nil {
75
+ error. memory = NSError ( domain: " HTTP_ERROR_CODE " , code: httpResponse. statusCode, userInfo: nil )
76
+ }
76
77
}
77
-
78
78
return false
79
79
}
80
80
}
0 commit comments