Created
September 27, 2014 07:03
-
-
Save tokorom/d744db2170ea97d05eb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 最適化によりnilが返っちゃうfunction | |
func parseFacebookUserDictionary(dictionary: NSDictionary) -> FacebookUserInformation? { | |
if let dict = dictionary as? [String : AnyObject] { | |
let information = FacebookUserInformation(dictionary: dict) | |
return information | |
} | |
return nil | |
} | |
// nilが返らないfunction | |
func parseFacebookUserDictionary(dictionary: NSDictionary) -> FacebookUserInformation? { | |
if let dict = dictionary as? [String : AnyObject] { | |
println("\(dictionary.count)") //< この行を外すと誤った最適化がされるので注意!! | |
let information = FacebookUserInformation(dictionary: dict) | |
return information | |
} | |
return nil | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
最適化レベルを
-O
(Releaseビルドのデフォルト) から-Onone
(Debugビルドのデフォルト) に変更すると、どちらもきちんと値が返るようになります。