This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended. To summarise this work: - [x] created a new **Xcode** project; - [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project; - [x] created the `Locations` app and also, its `Libraries` package; - [x] created the `Shared` package to share dependencies between the apps; - [x] added a `Makefile` file and implemented some **environment** and **help** commands. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: rock-n-code/deep-linking-assignment#1
30 lines
1.4 KiB
Objective-C
30 lines
1.4 KiB
Objective-C
#import <WMF/WMFLegacySerializer.h>
|
|
#import <WMF/NSError+WMFExtensions.h>
|
|
#import <WMF/WMF-Swift.h>
|
|
|
|
@implementation WMFLegacySerializer
|
|
|
|
+ (nullable NSArray *)modelsOfClass:(Class)modelClass fromArrayForKeyPath:(NSString *)keyPath inJSONDictionary:(nullable NSDictionary *)JSONDictionary languageVariantCode:(nullable NSString *)languageVariantCode error:(NSError **)error {
|
|
NSArray *maybeJSONDictionaries = [JSONDictionary valueForKeyPath:keyPath];
|
|
|
|
if (![maybeJSONDictionaries isKindOfClass:[NSArray class]]) {
|
|
if (error) {
|
|
*error = [WMFFetcher unexpectedResponseError];
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
return [self modelsOfClass:modelClass fromUntypedArray:maybeJSONDictionaries languageVariantCode: languageVariantCode error:error];
|
|
}
|
|
|
|
// Filters the untyped array to only include NSDictionary objects before serializing into modelClass
|
|
+ (nullable NSArray *)modelsOfClass:(Class)modelClass fromUntypedArray:(NSArray *)untypedArray languageVariantCode:(nullable NSString *)languageVariantCode error:(NSError **)error {
|
|
NSArray *JSONDictionaries = [untypedArray wmf_select:^BOOL(id _Nonnull maybeJSONDictionary) {
|
|
return [maybeJSONDictionary isKindOfClass:[NSDictionary class]];
|
|
}];
|
|
|
|
return [MTLJSONAdapter modelsOfClass:modelClass fromJSONArray:JSONDictionaries languageVariantCode: languageVariantCode error:error];
|
|
}
|
|
|
|
@end
|