feat: Handle weather code as nullable parameter
This commit is contained in:
@@ -16,6 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param prettyPrint If YES, uses white space and indentation to make the output more readable.
|
||||
- (NSString *)eqn_jsonStringWithPrettyPrint:(BOOL)prettyPrint;
|
||||
|
||||
/// Returns the value associated with a given key if exists, nil otherwise.
|
||||
/// @param aKey The key for which to return the corresponding value
|
||||
- (nullable id)eqn_safeObjectForKey:(id)aKey;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -24,4 +24,13 @@
|
||||
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
- (id)eqn_safeObjectForKey:(id)aKey
|
||||
{
|
||||
NSObject *object = [self objectForKey:aKey];
|
||||
if (object == [NSNull null]) {
|
||||
return nil;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, strong) NSNumber *preliminary;
|
||||
@property (nonatomic, strong) NSNumber *smartphoneNumber;
|
||||
@property (nonatomic, strong) NSNumber *userNumber;
|
||||
@property (nonatomic, strong) NSString *weatherCode;
|
||||
@property (nonatomic, strong, nullable) NSString *weatherCode;
|
||||
@property (nonatomic, strong) NSString *weatherIcon;
|
||||
@property (nonatomic, strong) NSNumber *weatherCloud;
|
||||
@property (nonatomic, strong) NSNumber *weatherWindSpeed;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#import "EQNSisma.h"
|
||||
#import "EQNUser.h"
|
||||
#import "EQNUtility.h"
|
||||
#import "NSDictionary+EQNExtensions.h"
|
||||
|
||||
@implementation EQNSisma
|
||||
|
||||
@@ -42,7 +43,7 @@
|
||||
self.smartphoneNumber = info[@"sm"];
|
||||
self.userNumber = info[@"rp"];
|
||||
|
||||
self.weatherCode = info[@"wc"];
|
||||
self.weatherCode = [info eqn_safeObjectForKey:@"wc"];
|
||||
self.weatherIcon = info[@"ic"];
|
||||
self.weatherCloud = info[@"cl"];
|
||||
self.weatherWindSpeed = info[@"ws"];
|
||||
|
||||
Reference in New Issue
Block a user