Releases: 3lvis/Sync
Sync — 1.14.2 (Swift 2.3)
- Fixed an issue with updating to-many relationships
Sync — 2.1.1
Update NSManagedObject-HYPPropertyMapper
dependency to fix an issue with mapping to binary data attributes
Sync — 1.14.1
Update NSManagedObject-HYPPropertyMapper
dependency to fix an issue with mapping to binary data attributes.
Sync — 2.1.0
🎁 It's been a while since a release this big happened. 🎁
This changes are also available for Swift 2.3 in Sync 1.14.0.
Depth Mapping
Foreverland/SYNCPropertyMapper#115 Thanks @marthinfreij! 🍰
Now you can map more than a simple value to a dictionary key! Now you can also reference values in dictionaries that have dictionaries inside them. Basically:
{
"user": {
"first_name": "Sam"
}
}
Now if you set your hyper.remoteKey
to user.first_name
, to your firstName
attribute, then BOOM. Sync
will know how to map it. And this works for all depth levels (I only tried 2, but I'm sure it can do INFINITE).
Value Transformations
Foreverland/SYNCPropertyMapper#117 Thanks @marthinfreij! 🍰:cake:
Sometimes values in a REST API are not formatted in the way you want them, resulting in you having to extend your model classes with methods and/or properties for transformed values.
For example, what if I want to encode this title before setting it to my model?
{
"title": "Foo & bar"
}
This requires your client to handle HTML entitles each time you need title
, or using transformable attributes which would make your title
a NSData.
Welp, not anymore!
First, open your Core Data model and the name of your transformer to hyper.valueTransformer
. For this example we'll use HYPTitleEncodingValueTransformer
.
#import "HYPTitleEncodingValueTransformer.h"
@implementation HYPTitleEncodingValueTransformer
+ (Class)transformedValueClass {
return [NSString class];
}
+ (BOOL)allowsReverseTransformation {
return YES;
}
- (id)transformedValue:(id)value {
if (value == nil) return nil;
NSString *stringValue = nil;
if ([value isKindOfClass:[NSString class]]) {
stringValue = (NSString *)value;
} else {
[NSException raise:NSInternalInconsistencyException
format:@"Value (%@) is not of type NSString.", [value class]];
}
return [stringValue stringByReplacingOccurrencesOfString:@"&" withString:@"&"];
}
- (id)reverseTransformedValue:(id)value {
if (value == nil) return nil;
NSString *stringValue = nil;
if ([value isKindOfClass:[NSString class]]) {
stringValue = (NSString *)value;
} else {
[NSException raise:NSInternalInconsistencyException
format:@"Value (%@) is not of type NSString.", [value class]];
}
return [stringValue stringByReplacingOccurrencesOfString:@"&" withString:@"&"];
}
@end
Then before hyp_fillWithDictionary
we'll do
[NSValueTransformer setValueTransformer:[[HYPTitleEncodingValueTransformer alloc] init] forName:@"HYPTitleEncodingValueTransformer"];
That's it! Then your title will be "Foo & bar"
.
It works the other way as well! So using hyp_dictionary
will return "Foo & bar"
Non-exportable Attributes
Foreverland/SYNCPropertyMapper#112 Thanks @Sorix 💐
Right now using hyp_dictionary
will make a JSON of all your attributes, if you want to skip any attribute, just set hyper.nonExportable
to true
and all your problems will be solved! I mean, not all of them, but maybe some...
Removed nasty NSLock logging
[NSLock unlock]: lock ( '(null)') unlocked when not locked
Foreverland/NSString-HYPNetworking#16 @pwestrich KICKING ASS! 👊
We've converted all the areas protected by NSLock to ones executed on a private serial dispatch queue. Hopefully this nasty warning will go away.
Other Bug Fixes
Foreverland/SYNCPropertyMapper#119
Fixed an issue with using hyp_dictionary
. In reserved attributes such as description
and the entity OrderedUser
. It was exporting ordered_user_description
instead of just description
.
Final notes
I've been really busy at work and haven't had the time to look closely to bug reports. I'm sorry if this is blocking you or affecting you in any way, sadly it's gonna be like this at least until beginning of next month. I'm going to make sure to help as much as I can if you want to resolve any of the bugs.
I'm also really happy and super grateful for all the contributions to make this release possible. Damn, you all are awesome. Keep it up!
Sync — 1.14.0
Swift 2.3 version
For full release notes here
Sync — 2.0.0
Swift 3 release. If you're on Swift 2.3 use this in your Podfile:
pod 'Sync', '~> 1'
Sync — 1.13.3
The feature that would make you remove all your expectationWithDescription
and waitForExpectationsWithTimeout
.
Sync should run synchronously in automatic test environments.
Sync — 1.13.2
- Add support for returning nil when mapping
test_!_key
in JSON, before it was crashing.
Sync — 1.13.1
Added support for clearing relationships between many-to-many relationships #225
Model
Case 1: Replacing a tag with another tag (Fixed)
First tag 10 gets inserted and assigned to user.
[
{
"id": 1,
"tags": [
{
"id": 10
}
]
}
]
Then tag 10 gets removed and tag 20 gets assigned to user instead. Tag 10 gets removed.
[
{
"id": 1,
"tags": [
{
"id": 20
}
]
}
]
Case 2: Removing a tag with an empty array (Fixed)
First tag 10 gets inserted and assigned to user.
[
{
"id": 1,
"tags": [
{
"id": 10
}
]
}
]
Then tag 10 gets detached from user. Tag 10 gets removed.
[
{
"id": 1,
"tags": []
}
]
Case 3: Removing a tag with null (Fixed)
First tag 10 gets inserted and assigned to user.
[
{
"id": 1,
"tags": [
{
"id": 10
}
]
}
]
Then tag 10 gets detached from user. Tag 10 gets removed.
[
{
"id": 1,
"tags": null
}
]
Sync — 1.13.0 (with support for super-entities)
Adds support for syncing entities that have super entities (just one level for now), for example, adding passengers to with a list of Racecars. All thanks to the fantastic @Jonge! Thanks ❤️.
Model
JSON
[
{
"id": 31,
"max_speed": 370,
"passengers": [
{
"id": 22,
"name": "Jenson Button"
},
{
"id": 7,
"name": "Kimi Raikkonen"
}
]
}
]