Sync

JSON to Core Data and back. Swift Core Data Sync.

OTHER License

Stars
2.6K
Committers
33

Bot releases are visible (Hide)

Sync - Sync — 2.3.0

Published by 3lvis almost 8 years ago

  • Changed NSManagedObject_HYPPropertyMapper with SYNCPropertyMapper.

You might need to replace any:

import NSManagedObject_HYPPropertyMapper

With:

import SYNCPropertyMapper

And:

// Before
hyp_remote

// After
hyp_snakeCase
// Before
hyp_local

// After
hyp_camelCase
Sync - Sync — 1.15.0 (Swift 2.3)

Published by 3lvis about 8 years ago

  • Reduced dependencies

You might need to replace any broken imports with

import NSManagedObject_HYPPropertyMapper
Sync - Sync — 2.2.0

Published by 3lvis about 8 years ago

  • Reduced dependencies

You might need to replace any broken imports with

import NSManagedObject_HYPPropertyMapper
Sync - Sync — 1.14.4 (Swift 2.3)

Published by 3lvis about 8 years ago

  • Move to new organization
Sync - Sync — 2.1.6 (Swift 3)

Published by 3lvis about 8 years ago

  • Moved to a new organization
Sync - Sync — 2.1.5 (Swift 3)

Published by 3lvis about 8 years ago

  • Moved one of the dependencies
Sync - Sync — 2.1.4 (Swift 3)

Published by 3lvis about 8 years ago

  • Remove print calls
Sync - Sync — 2.1.3 (Swift 3)

Published by 3lvis about 8 years ago

Sync - Sync — 1.14.3 (Swift 2.3)

Published by 3lvis about 8 years ago

Sync - Sync — 1.14.2 (Swift 2.3)

Published by 3lvis about 8 years ago

  • Fixed an issue with updating to-many relationships

https://github.com/hyperoslo/Sync/issues/280

Sync - Sync — 2.1.2 (Swift 3)

Published by 3lvis about 8 years ago

  • Fixed an issue with updating to-many relationships

https://github.com/hyperoslo/Sync/issues/280

Sync - Sync — 1.14.1

Published by 3lvis about 8 years ago

Update NSManagedObject-HYPPropertyMapper dependency to fix an issue with mapping to binary data attributes.

Sync - Sync — 2.1.1

Published by 3lvis about 8 years ago

Update NSManagedObject-HYPPropertyMapper dependency to fix an issue with mapping to binary data attributes

Sync - Sync — 2.1.0

Published by 3lvis about 8 years ago

🎁 It's been a while since a release this big happened. 🎁

Celebrate

This changes are also available for Swift 2.3 in Sync 1.14.0.

Depth Mapping

https://github.com/hyperoslo/NSManagedObject-HYPPropertyMapper/pull/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

https://github.com/hyperoslo/NSManagedObject-HYPPropertyMapper/pull/117 Thanks @marthinfreij! 🍰🍰

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

https://github.com/hyperoslo/NSManagedObject-HYPPropertyMapper/issues/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

https://github.com/hyperoslo/NSString-HYPNetworking/pull/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

https://github.com/hyperoslo/NSManagedObject-HYPPropertyMapper/pull/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 - Sync — 1.14.0

Published by 3lvis about 8 years ago

Swift 2.3 version

For full release notes here

Sync - Sync — 2.0.0

Published by 3lvis about 8 years ago

Swift 3 release. If you're on Swift 2.3 use this in your Podfile:

pod 'Sync', '~> 1'
Sync - Sync — 1.13.3

Published by 3lvis about 8 years ago

The feature that would make you remove all your expectationWithDescription and waitForExpectationsWithTimeout.

Sync should run synchronously in automatic test environments.

Sync - Sync — 1.13.2

Published by 3lvis about 8 years ago

  • Add support for returning nil when mapping test_!_key in JSON, before it was crashing.
Sync - Sync — 1.13.1

Published by 3lvis about 8 years ago

Added support for clearing relationships between many-to-many relationships https://github.com/hyperoslo/Sync/issues/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 - Sync — 1.13.0 (with support for super-entities)

Published by 3lvis about 8 years ago

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"
      }
    ]
  }
]
Package Rankings
Top 16.93% on Carthage
Top 1.36% on Cocoapods.org