Added NSProgress
- Added
NSProgress
support
You can track progress using
[mapper.progress addObserver:self
forKeyPath:NSStringFromSelector(@selector(fractionCompleted))
options:NSKeyValueObservingOptionNew
context:NULL];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
if ([keyPath isEqualToString:NSStringFromSelector(@selector(fractionCompleted))] && [object isKindOfClass:[NSProgress class]]) {
NSLog(@"Mapping progress = %f", [change[@"new"] doubleValue]);
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
It also supports cancellation
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
[mapper mapFromRepresentation:JSON mapping:employeeMapping completion:^(NSArray *mappedObjects, NSError *error) {
NSLog(@"Mapped objects %@ - Error %@", mappedObjects, error);
}];
});
[mapper.progress cancel];
- Added a basic sample on view controller