Comments (6)
from mantle.
Think this makes sense to me. 👍
from mantle.
pretty and 👍
from mantle.
yep 👍
from mantle.
Is there a recommended way to opt out of this behavior?
My current solution is to subclass MTLJSONAdapter
.
+ (NSValueTransformer<MTLTransformerErrorHandling> *)arrayTransformerWithModelClass:(Class)modelClass
{
NSValueTransformer<MTLTransformerErrorHandling> *transformer = [super arrayTransformerWithModelClass:modelClass];
return [MTLValueTransformer transformerUsingForwardBlock:^id(id value, BOOL *success, NSError *__autoreleasing *error) {
NSArray *models = [transformer transformedValue:value success:success error:error];
if ([models containsObject:[NSNull null]]) {
if (error != NULL) {
NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: NSLocalizedString(@"Could not convert JSON array to model array", @""),
NSLocalizedFailureReasonErrorKey: NSLocalizedString(@"Array contained a null object. This is not supported.", nil) };
*error = [NSError errorWithDomain:MTLTransformerErrorHandlingErrorDomain code:MTLTransformerErrorHandlingErrorInvalidInput userInfo:userInfo];
}
*success = NO;
return nil;
}
return models;
} reverseBlock:^id(id value, BOOL *success, NSError *__autoreleasing *error) {
if ([transformer respondsToSelector:@selector(reverseTransformedValue:success:error:)]) {
return [transformer reverseTransformedValue:value success:success error:error];
}
return nil;
}];
}
from mantle.
That seems like a sensible approach to me 👍
from mantle.
Related Issues (20)
- Missing header files HOT 1
- Potential leak of memory reported by Xcode static analysis HOT 1
- FR: Add xcframework in a zip file in tag version on github HOT 1
- Map multiple json field when key name is same HOT 2
- Parsing array with objects of different subclasses
- FR: Add precompiled xcframework in assets. HOT 4
- fix build for Xcode 12.5 HOT 1
- Document is so difficult to understand and still so complex to use HOT 2
- Should auto transform json value type to property type without create transformer HOT 2
- JsonToModel error HOT 2
- The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. HOT 9
- Getting crash in iOS 15
- Can't install version 2.2.0 using pods HOT 7
- Handling null values when mapping to a BOOL property HOT 4
- Mantle crashes on iOS 16 due to WorkflowKit containing an unprefixed Mantle copy HOT 6
- strncpy code security issue HOT 2
- Error when activating code coverage HOT 2
- dSYM files of Mantle HOT 3
- Redefinition of enumerator 'MTLModelEncodingBehaviorExcluded' HOT 1
- Excuse me. Is there any plan to release the next release? When is the release planned? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mantle.