Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Releases: JohnSundell/Unbox

Unbox 2.1

09 Oct 21:38
Compare
Choose a tag to compare
  • You can now manually create Unboxer instances with either an UnboxableDictionary or Data. This gives you more flexibility and control over the unboxing process (compared to calling unbox(), which makes Unbox create an Unboxer for you).
  • Unbox now correctly handles Int32, Int64, UInt32 and UInt64, even on 32 bit systems.

Unbox 2.0

03 Oct 23:48
Compare
Choose a tag to compare

Unbox 2.0 brings a new, streamlined API and reworked internals for maximum flexibility & performance.

⚠️ This release includes breaking changes for users of Unbox 1.9 or earlier. Please read these notes carefully and upgrade with caution. It's also only compatible with Swift 3 (for Swift 2 compatibility, use the swift2 branch.

All APIs have been reworked to follow the Swift 3 API naming guidelines

  • Unbox(_) is now unbox(dictionary:), unbox(data:) and unbox(dictionaries:).
  • UnboxableWithContext.ContextType is now UnboxContext.
  • UnboxableByTransform.UnboxRawValueType is now UnboxRawValue.
  • Wherever key paths were supported with the isKeyPath: argument, that has now been replaced with key: and keyPath: overloads. For example unboxer.unbox("company.title", isKeyPath: true) is now unboxer.unbox(keyPath: "company.title").
  • The UnboxError enum now uses non-captailized first letters for its cases.
  • UnboxableKey.transformUnboxedKey() is now transform(unboxedKey:).
  • UnboxableByTransform.transformUnboxedValue() is now transform(unboxedValue:).
  • UnboxFormatter.formatUnboxedValue() is now format(unboxedValue:).
  • Unboxer.performCustomUnboxingWithDictionary() is now performCustomUnboxing(dictionary:)
  • Unboxer.performCustomUnboxingWithArray() is now performCustomUnboxing(array:)
  • Unboxer.performCustomUnboxingWithData() is now performCustomUnboxing(data:)

Swift native error handling model

Unboxable and UnboxableWithContext types can now throw from their initializer. This enables you to easily manually exit from an initializer, without having to use any specific APIs on Unboxer.

This new capability is also used when performing unboxing of values. Now, all required properties are unboxed using try, meaning that as soon as an error as been encountered, the initializer will be exited. This gives us a huge performance boost when dealing with malformed data, or when allowing invalid elements.

It also means that the unboxFallbackValue() function has been removed, and is no longer required to be implemented by types.

Finally, since now only one error can be thrown from an unboxing process (since we exit early) - UnboxError and UnboxValueError have been merged, and there's no longer a hasFailed property on Unboxer.

Any combination of arrays & dictionaries are now directly unboxable

Previously, Unbox only supported combinations of types and collections that were defined as overloads on Unboxer. Now, thanks to a reworked value resolving system, any combination of types and collections are supported. You can now directly unbox even the most complex data structures with one simple call to unbox().

Removals

Some APIs that have been kept around for legacy reasons have been removed in this release.

  • You can no longer send a context when starting the unboxing process for Unboxable types. Instead, use UnboxableWithContext, which gives you strong typing for your contextual object.
  • UnboxableWithFormatter has been removed, since it wasn't needed. Formatting is still 100% supported, through the use of the UnboxFormatter API.

Unbox 1.9

26 Jul 20:30
Compare
Choose a tag to compare
  • You can now Unbox an array of UnboxableByTransform types (thanks @maxsz!)
  • You can now start Unboxing at a certain key/keyPath instead of having to create an intermediate struct (thanks @clayellis!)
  • You can now send a context when unboxing a nested Unboxable type.
  • An array of strings can now be directly unboxed to an array of another raw type (thanks @clayellis!)

Unbox 1.8

01 Jul 10:34
Compare
Choose a tag to compare

This release contains great new features implemented by the ever growing Unbox community!

  • The custom unboxing API for arrays now supports allowing invalid elements (like the other array-based APIs). Thanks to @PSchu!
  • Nested dictionary support has been heavily improved (they can, for instance, now contain nested arrays in turn, making you able to unbox a deep structure in one go). Thanks @johannth!
  • You can now directly unbox an array with values that will be formatted using a formatter (and optionally allowing invalid elements too!). Thanks to @mikezs!

Unbox 1.7 - 1 year anniversary edition!

04 Jun 19:54
Compare
Choose a tag to compare

Unbox is 1 year old today, let's celebrate with a release 🎉

  • Unbox can now automatically convert most numbers to their expected type. The following types are supported: Ints, Bool, UInt, Int32, Int64, Double, Float.
  • The isKeyPath parameter's default value is now true, meaning that in order to use keypaths, less code needs to be written.

Unbox 1.6

25 May 21:08
Compare
Choose a tag to compare
  • Errors for missing and/or invalid values are now thrown as an array, so that you can see all errors that were encountered at once - reducing debugging times! Thanks @Evertt for implementing this!

  • An UnboxableByTransform's raw type can now be a collection (so you can use it to transform not only raw values, but also collections).

  • Type safety for Arrays & Dictionaries has been improved. They can now only be unboxed if they:

    A) Are explicitly typed as [AnyObject] or [String : AnyObject]
    B) Contain only raw values (like Int, String, etc)
    C) Contain nested collections

Unbox 1.5.2

14 May 13:48
Compare
Choose a tag to compare

This release contains fixes from the evergrowing Unbox community! 🚀

  • Swift Package Manager (SPM) is now supported (thanks @alexaubry!)
  • OS X 10.10 is now supported, just as 10.11 (thanks @bmichotte!)
  • Custom unboxing closures can now throw (thanks @pureblood!)

Unbox 1.5.1

05 May 11:20
Compare
Choose a tag to compare
  • Key path based unboxing now supports retrieving an element from a nested array (thanks @BalestraPatrick for implementing this!)
  • Unbox will now automatically convert strings to numbers if you're expecting a number type and a string was found.

Unbox 1.5

28 Apr 19:11
Compare
Choose a tag to compare

This release makes improvements to the main Unbox() API, as well as when working with collections.

  • Unbox() and UnboxOrThrow() have been merged into Unbox() - that is now a throwing function. The same behavior as when using UnboxOrThrow() can still be achieved using try? Unbox().
  • When unboxing an array or dictionary containing Unboxable dictionaries, an allowInvalidElements parameter has been added, to optionally (it defaults to false) skip invalid elements that couldn't be unboxed - and instead of failing the process returning a collection with all valid elements.
  • Unbox now supports collections with nested collections inside of them.
  • The project now uses single plist files for tests and for the framework.

Thanks to @basememara, @acecilia, @Abizern for their work on this release 🎉

Unbox 1.4

23 Mar 20:44
Compare
Choose a tag to compare

This release mostly includes improvements by the growing Unbox community 🚀

  • Unbox now uses the latest Swift 2.2 syntax without warnings (thanks @Iyuna).
  • Unboxing of arrays of enum values is now supported (thanks @mikezs).
  • The Custom Unboxing API now supports arrays of dictionaries.
  • Misc small bug fixes & project settings updates.