FBLoginCutomUISample을 목표 C에서 swift로 변환하려고합니다. 지금까지 모든 것이 잘 작동합니다. 나는 다음과 같은 몇 가지 솔루션 시도NSDictionnary를 목표 C에서 swift로 변환하십시오.
//Get more error information from the error
NSDictionary *errorInformation = [[[error.userInfo objectForKey:@"com.facebook.sdk:ParsedJSONResponseKey"] objectForKey:@"body"] objectForKey:@"error"];
// Show the user an error message
alertTitle = @"Something went wrong";
alertText = [NSString stringWithFormat:@"Please retry. \n\n If the problem persists contact us and mention this error code: %@", [errorInformation objectForKey:@"message"]];
[self showMessage:alertText withTitle:alertTitle];
: 난 그냥이 시점에 박히면서
if let info = error.userInfo {
let errorInformation = info["com.facebook.sdk:ParsedJSONResponseKey"]["body"]["error"]
let msg = errorInformation["message"]
println("errormessage: \(msg)")
}
를하지만 때마다 나에게 같은 오류를 제공합니다 : '(NSObject의, AnyObject)'는이 없습니다 'subscript'라는 이름의 멤버. 그것은 풀리지 않는 문제인 것처럼 보이지만 어떻게 해결해야할지 모르겠습니다. 감사합니다
[UPDATE 해결 방법] 드디어 여기에 작업 코드를 업데이트 할 수 있습니다 아래의 대답에서
:
if let info = error.userInfo{
if let dict1 = info["com.facebook.sdk:ParsedJSONResponseKey"] as? NSDictionary {
if let dict2 = dict1["body"] as? NSDictionary {
if let errorInformation = dict2["error"] as? NSDictionary {
if let msg:AnyObject = errorInformation["message"] {
println("errormessage: \(msg)")
}
}
}
}
}
배열/사전 참조. ..]'는 객체에 대한 "subscript"메소드를 호출합니다. 컴파일러는 가지고있는 객체의 종류를 알지 못합니다. –