SwifterSwift v4.5.0 Release Notes

Release Date: 2018-09-21 // over 5 years ago
  • โž• Added

    • CGVector
      • Added angle computed property to get the angle of the vector (in radians). #527 by moyerr
      • Added magnitude computed property to get the magnitude (or length) of the vector. #527 by moyerr
      • Added scalar multiplication of CGFloat and CGVector via standard multiplication operator (*). #527 by moyerr
      • Added negation of vectors via prefix (-) operator. #527 by moyerr
      • Added init(angle:magnitude:) to create vectors based on their angle and magnitude. #527 by moyerr -UIRefreshControl:
      • beginRefresh(in tableView:, animated:, sendAction:) UIRefreshControl extension to begin refresh programatically. #525 by ratulSharker
    • Dictionary:
      • Added removeValueForRandomKey() to remove a value for a random key from a dictionary. #497 by MaxHaertwig.
      • Added mapKeysAndValues(_:) to map a Dictionary into a Dictionary with different (or same) Key and Value types. #546 by guykogus
      • Added compactMapKeysAndValues(_:) to map a Dictionary into a Dictionary, excluding nil results, with different (or same) Key and Value types. #546 by guykogus
      • Added keys(forValue:) which returns an array of all keys that have the given value in dictionary. #561 by mauliksharma.
    • RangeReplaceableCollection:
      • Added removeRandomElement() to remove a random element from a collection. #497 by MaxHaertwig.
    • UIView
      • Added addGestureRecognizers(_:) which accepts an array of UIGestureRecognizer to add multiple gesture recognizers to a view with one call. #523 by moyerr
      • Added removeGestureRecognizers(_:) which accepts an array of UIGestureRecognizer to remove multiple gesture recognizers from a view with one call. #523 by moyerr
    • UIViewController
      • Added addChildViewController(_:toContainerView) to easily add child view controllers. Accepts a UIViewController and a UIView to add the child's view to.
      • Added removeViewAndControllerFromParentViewController() to remove a UIViewController from its parent.
    • NSView
      • Added backgroundColor which allows to change backgroundColor of NSView #702 by RomanPodymov
    • UIEdgeInsets
      • Added insetBy(top:), insetBy(left:), insetBy(bottom:), insetBy(right:), insetBy(horizontal:) and insetBy(vertical:) to creates an UIEdgeInsets based on current value and adjusted by given offset. #532 by VincentSit.
      • Added operators + and += to add two insets together in order to extend them. #557 by guykogus
    • UILayoutPriority
      • Added init(floatLiteral value: Float) initializer to initialize priority with float literal. #549 by diamantidis.
      • Added init(integerLiteral value: Int) initializer to initialize priority with integer literal. #549 by diamantidis.
    • RangeReplaceableCollection
      • init(expression:count:) to create a collection of a given count initialized with an expression.#537 by LucianoPAlmeida.
    • Optional:
      • Added ?= operator to assign to nil optionals only. #538 by viktart
    • Data:
      • Added jsonObject(options:) to convert a data object into a JSON object. #542 by guykogus
    • URL
      • Added droppedScheme() which returns new URL that does not have scheme. #528 by sammy-sc
    • CGSize
      • Added operator + to return the addition of two CGSize.
      • Added operator += to add a CGSize to another.
      • Added operator - to return the subtraction of two CGSize.
      • Added operator -= to subtract a CGSize from another.
      • Added operator CGSize * CGSize to return the multiplication of two CGSize.
      • Added operator CGSize * CGFloat and CGFloat * CGSize to return the multiplication of a CGSize and a CGFloat value.
      • Added operator CGSize *= CGSize to multiply a CGSize with another one.
      • Added operator CGSize *= CGFloat to multiply a CGSize with a CGFloat value.
    • UIImage:
      • Added rotate(by:) for generating rotated versions of images. There are 2 versions, one where the angle is passed directly as a CGFloat in radians, the other using the Measurement class, which is only available for iOS 10+/tvOS 10+/watchOS 3+. #555 by guykogus

    ๐Ÿ”„ Changed

    • RangeReplaceableCollection:
      • rotate(by:) and rotated(by:) array extensions now are more generic RangeReplaceableCollection extensions. #512 by LucianoPAlmeida.
      • removeFirst(where:) array extension now is more generic RangeReplaceableCollection extensions. #516 by LucianoPAlmeida.
    • RandomAccessCollection:
      • indices(of:) array extension now is more generic RandomAccessCollection extensions. #516 by LucianoPAlmeida.
    • UIView:
      • Improved performance in fillToSuperview() UIView extension. #540 by viktart

    ๐Ÿ›  Fixed

    • UIImage:
    • ๐Ÿ›  Fixed scaled(toWidth:, with orientation:) and scaled(toHeight:, with orientation:) were using image's scale as the scale factor. #515 by VincentSit.
    • String:
      • Used RFC 5322 in isValidEmail, an email address regex that 99.99% works. #517 by Omar Albeik
      • Fixed unicodeArray() not returning the correct unicode value due to Swift 4.2 new hashing system. #544 by Omar Albeik

    ๐Ÿ—„ Deprecated

    • String:
      • isEmail property has been renamed to isValidEmail.

    โœ‚ Removed

    ๐Ÿ”’ Security