1
ユーザーにサインアップすると、ステータスコード200とトークン "JSON"が返されます。 ユーザーが既に存在する場合、JSONの代わりにステータスコード200とhtml応答が返されます。この問題はどのように処理するべきですか?前もって感謝します。サインアップ時のJSONデータ処理
私が行っていることである -
switch httpResponse.statusCode {
case 200:
// 2. Create JSON object with data
do {
let jsonDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? [String: AnyObject]
print(jsonDictionary!)
if let jsonDictionaryOne = jsonDictionary {
let authToken = AuthToken(tokenDictionary: jsonDictionaryOne)
completion(authToken)
}
} catch {
print("Fetch failed: \((error as NSError).localizedDescription)")
dispatch_async(dispatch_get_main_queue()) {
let authToken = AuthToken(tokenDictionary: ["token":"none"])
completion(authToken)
}
}