Last active
August 29, 2015 14:17
-
-
Save VojtaStavik/c414d1495f786bd3b9c6 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
// Objective-C: | |
user.userId = @"unknown"; | |
if ([object isKinfOfClass:[NSDictionary class]]) { | |
if ([[((NSDictionary *)object) objectForKey:@"user_id"] isKindOfClass:[NSString class]]) { | |
user.userId = (NSString *)[((NSDictionary *)object) objectForKey:@"user_id"]; | |
} | |
} | |
// Swift: | |
user.userId = (object as? NSDictionary)?["user_id"] as? String ?? "unknown" | |
// that's all :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment