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
48 lines
1.3 KiB
Objective-C
48 lines
1.3 KiB
Objective-C
//
|
|
// NSDictionary+MTLJSONKeyPath.m
|
|
// Mantle
|
|
//
|
|
// Created by Robert Böhnke on 19/03/14.
|
|
// Copyright (c) 2014 GitHub. All rights reserved.
|
|
//
|
|
|
|
#import "NSDictionary+MTLJSONKeyPath.h"
|
|
|
|
#import "MTLJSONAdapter.h"
|
|
|
|
@implementation NSDictionary (MTLJSONKeyPath)
|
|
|
|
- (id)mtl_valueForJSONKeyPath:(NSString *)JSONKeyPath success:(BOOL *)success error:(NSError **)error {
|
|
NSArray *components = [JSONKeyPath componentsSeparatedByString:@"."];
|
|
|
|
id result = self;
|
|
for (NSString *component in components) {
|
|
// Check the result before resolving the key path component to not
|
|
// affect the last value of the path.
|
|
if (result == nil || result == NSNull.null) break;
|
|
|
|
if (![result isKindOfClass:NSDictionary.class]) {
|
|
if (error != NULL) {
|
|
NSDictionary *userInfo = @{
|
|
NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid JSON dictionary", @""),
|
|
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedString(@"JSON key path %1$@ could not resolved because an incompatible JSON dictionary was supplied: \"%2$@\"", @""), JSONKeyPath, self]
|
|
};
|
|
|
|
*error = [NSError errorWithDomain:MTLJSONAdapterErrorDomain code:MTLJSONAdapterErrorInvalidJSONDictionary userInfo:userInfo];
|
|
}
|
|
|
|
if (success != NULL) *success = NO;
|
|
|
|
return nil;
|
|
}
|
|
|
|
result = result[component];
|
|
}
|
|
|
|
if (success != NULL) *success = YES;
|
|
|
|
return result;
|
|
}
|
|
|
|
@end
|