SwifterSwift v5.2.0 Release Notes

Release Date: 2020-04-05 // over 2 years ago
  • โž• Added

    • CATransform3D:
      • identity, isIdentity, init(translationX:y:z:), init(scaleX:y:z:), init(rotationAngle:x:y:z:), translatedBy(x:y:z:), scaledBy(x:y:z:), rotated(by:x:y:z:), inverted(), concatenating(_:), translateBy(x:y:z:), scaleBy(x:y:z:), rotate(by:x:y:z:), invert(), concatenate(_:), isAffine and affineTransform(). Also conforms to Codable and Equatable. #819 by guykogus
    • CGAffineTransform:
    • NotificationCenter:
      • observeOnce(forName:object:queue:using:) for observing a single posting of a notification. #812 by guykogus
    • Optional:
      • Conform to Equatable when Wrapped is RawRepresentable and its RawValue is Equatable. #804 by guykogus
    • CoreLocation:
      • Added Array where Element: CLLocation extension and added distance(unitLength:) function. #799 by trevorphillips
    • Decodable:
      • Added init?(data:decoder:) to decode Decodable (Codable) type models. #797 by Mustafa GUNES.
    • CLVisit:
    • EdgeInsets:
      • Unified UIEdgeInsets and NSEdgeInsets into a single typealias, EdgeInsets, similar to what we do with UIColor and NSColor. For the tests to function it was required to add the static zero property to NSEdgeInsets and to make it conform to Equatable. #785 by guykogus
    • Array:
      • Added sorted(like:keyPath:) to sort an array like another array based on a key path. #772 by MaxHaertwig.
    • MKMapView:
      • Added zoom(to:meter:edgePadding:animated:) method to zoom multiple MKMapView coordinates. #723 by Mustafa GUNES.
    • Dictionary:
      • Added init(grouping:by:) to initialize a dictionary by grouping sequence from a hashable KeyPath. #751 by mmdock
    • RangeReplaceableCollection:
      • Added removeDuplicates(keyPath:) for removing duplicate elements based on key path. #737 by Ilya Glushchuk.
      • Added appendIfNonNil(_:) and appendIfNonNil(contentsOf:) methods that can append optional elements and sequences. #966 by jevonmao
    • Color:
      • Added init(light:dark:) to create an NSColor/UIColor with different variations for light and dark mode. Only available in iOS/tvOS 13.0, macOS 10.15. #722 by MaxHaertwig.
    • String:
      • Added withPrefix(_:), which provides a method to add a prefix to a string. If the string already has that prefix, it simply returns the original string. #720 by Zach Frew.
    • NSRegularExpression:
      • Added enumerateMatches(in:options:range:using:), matches(in:options:range:), numberOfMatches(in:options:range:), firstMatch(in:options:range:), rangeOfFirstMatch(in:options:range:), stringByReplacingMatches(in:options:range:withTemplate:), replaceMatches(in:options:range:withTemplate:), which use String and String.Range in place of NSString and NSRange to make the calls Swifter. #727 by guykogus.
    • UIBarButtonItem:
      • Added flexibleSpace and fixedSpace(width:) extensions to UIBarButtonItem to simplify the creation of spacers. #728 by MaxHaertwig.
    • UIImage:
      • Added missing test for compressedData(quality:). #786 by thisIsTheFoxe
      • Added withBackgroundColor(_:) to specify a background color for a partially transparent image. #721 by MaxHaertwig.
      • Added init?(base64String:) to create a UIImage from a base-64 String. #741 by @thisIsTheFoxe
      • Added pngBase64String(), jpegBase64String(compressionQuality:) which return a Base 64 String representation of the UIImages PNG or JPEG data. #747 by Moritz Sternemann.
      • Added init?(url:scale:) to initialize a UIImage with a given url and scale factor. #753 by mmdock
    • CAGradientLayer:
      • Added init(colors:locations:startPoint:endPoint:type:) convenience initializer. #726 by JayMehta97.
    • Sequence:
      • Added sum(for:) to sum up an AdditiveArithmetic property, referenced by KeyPath, of all elements in a sequence. #736 by Moritz Sternemann.
      • Added sorted(by:and:) and sorted(by:and:and:) to obtain a sorted sequence based on multiple key paths. #796 by MaxHaertwig.
      • Added map(by:) to map the sequence elements by a given key path. #763 by Roman Podymov.
      • Added compactMap(by:) to map the sequence elements by a given key path to the non-nil elements array. #766 by Roman Podymov.
      • Added filter(by:) to filter the sequence elements by a given boolean key path. #771 by Roman Podymov.
    • MutableCollection:
      • Added assignToAll(value:keyPath:) to assign given value to field keyPath of every element in the collection. #759 by cyber-gh.
      • Added sort(by:and:) and sort(by:and:and:) to sort a sequence based on multiple key paths. #796 by MaxHaertwig.
    • KeyedDecodingContainer:
      • Added decodeBoolAsIntOrString(key:) to try to decode a Bool as Int then String before decoding as Bool. #750 by FraDeliro.
      • Added decodeBoolAsIntOrStringIfPresent(key:) to try to decode a Bool as Int then String before decoding as Bool if present. #750 by FraDeliro.
    • Locale:
      • Added is12HourTimeFormat to indicate if locale has 12h format. #793 by DimaZava.
      • flagEmoji(forRegionCode:) to convert a region code into the corresponding flag emoji. #813 by guykogus
    • URLRequest:
      • init(string:relativeTo:) to allow initializing a URL with an optional String. #818 by guykogus
      • Added curlString property to get a cURL command representation of this URL request. #790 by DimaZava.
    • SKProduct:
    • CGRect
      • Added property center. #814 by qchenqizhi.
      • Added initializer init(center:size:) to create CGRect with center and size. #814 by qchenqizhi.
      • Added resizing(to:anchor:) to create CGRect by resizing with anchor. #814 by qchenqizhi.

    ๐Ÿ”„ Changed

    • Collection:
      • Refactored group(by:) to be generic for all Collections, not only where Index == Int. #758 by guykogus
    • UIImage:
      • Implemented filled(withColor:) using UIGraphicsImageRenderer when available. #733
      • Updated kilobytesSize to be computed independently from bytesSize #753 by mmdock
      • Updated init?(base64String:) to take in a scale factor paramater. #753 by mmdock
    • UIImage:
      • Refactored tint(_:blendMode:) using UIGraphicsImageRenderer if available. #731 by FraDeliro.
    • Sequence:
      • Corrected documentation for sorted(by:with:) and sorted(by:). #751 by mmdock
    • NSAttributedString:
      • Update applying(attributes: [NSAttributedString.Key : Any], toRangesMatching pattern: String) to respond applying(attributes: [NSAttributedString.Key : Any], toRangesMatching pattern: String, options: NSRegularExpression.Options = []) signature to support regular expression options. #791 by DimaZava
    • UIButton:
      • Refactored centerTextAndImage(spacing:): now the image position can be above the text, by setting a new parameter imageAboveText to true. #807 by qchenqizhi.
    • String:
      • Bug fix String[safe:], subscript should not crash. #816 by cHaLkdusT

    ๐Ÿ›  Fixed

    • ๐Ÿ›  Fixed build error occurring when building AppKit extensions for macCatalyst. #762 by MaxHaertwig.
    • ๐Ÿ›  Fixed String.base64Decoded making it a safe decode by including padding on the string. #801 by LucianoPAlmeida.
    • ๐Ÿ›  Fixed UIImage.cropped(to:) making it work correctly with scaled image. #811 by qchenqizhi.