The changelog for SwifterSwift. Also see the releases on GitHub.
- Calendar
- Added
numberOfDaysInYear(for:)method to get the total number of days in a date's year. #1253 by William-Laverty
- Added
- Xcode
- UIFont
- Sequence
- Fixed documentation for
any.
- Fixed documentation for
- String
- UIView
- Android
- Added Android platform support. #1230 by Marc Prud'hommeaux
- CocoaPods
- String
localized(comment:)now supports all parameters provided byNSLocalizedString(tableName:bundle:value:comment:). #1217 by Shiki Suen
- Examples : Added "import Foundation" to Foundation Extension Playground page for Date() extension to work properly on Mac
- Array
- FloatingPoint
- Sequence's
count(where:)method, as it already exists in stdlib. #1221 by vikingosegundo
- Xcode 16
- Fixed compilation errors, warnings and tests. #1197 by guykogus
- Fixed additional compilation errors #1202 by denandreychuk
- CAGradientLayer
- CGAffineTransform
- Future
- URLSession
- NSView
- Added
addArrangedSubviews(_ views: )to add an array of views to the end of the arrangedSubviews array. #1181 by Roman Podymov - Added
removeArrangedSubviewsto remove all views in stack’s array of arranged subviews. #1181 by Roman Podymov
- Added
- Sequence
sorted(by:),sorted(by:with:),sorted(by:and:),sorted(by:and:and:),sum(for:),first(where:equals:)now have alternatives that receive functions as parameters. This change maintains compatibility with KeyPath while making the methods more flexible. #1170 by MartonioJunior
- Sequence
sorted(by:),sorted(by:with:),sorted(by:and:),sorted(by:and:and:),sum(for:),first(where:equals:)now have alternatives that receive functions as parameters. This change maintains compatibility with KeyPath while making the methods more flexible. #1170 by MartonioJuniorcontains(_:)forElement: Hashablenow can receive any type that conforms toSequence, not just anArray. #1169 by MartonioJunior
- PrivacyInfo.xcprivacy
- UIImageView
- Swift Package Manager
- Added a privacy manifest to comply with Apple's requirements regarding Describing use of required reason API. #1176 by guykogus
- Measurement
- Added
+=,-=,*=,/=to add, subtract, multiply and divide measurements. #1162 by Roman Podymov
- Added
- Sequence
- Added
product()for calculating the product of allNumericelements. #1168 by MartonioJunior - Added
product(for:)for calculating the product of theNumericproperty for all elements inSequence. #1168 by MartonioJunior
- Added
- UIView
- Added
removeBlur()method for removing the applied blur effect from the view. #1159 by regi93 - Added
makeCircle(diameter:)method to make the view circular. #1165 by happyduck-git
- Added
- UIImageView
- UIView
- Minimum deployment target
- Color
- Renamed typealias
Colortypealias toSFColorto fix namespace conflicts with swiftUI'sColorType. #1055 by MussaCharles
- Renamed typealias
- EdgeInsets
- Renamed
EdgeInsetstypealias toSFEdgeInsetsto fix namespace conflicts with swiftUI'sEdgeInsetsType. #1055 by MussaCharles
- Renamed
- Font
- Renamed
Fonttypealias toSFFontto fix namespace conflicts with swiftUI'sFontType. #1055 by MussaCharles
- Renamed
- String
- Array:
sorted(by:ascending:),sort(by:ascending:)
- Sequence:
map(by:),compactMap(by:),filter(by:),last(where:)
- String
init(randomOfLength:)
- UIDatePicker
textColor
- String
- UIDatePicker
- Future
- Added
init(asyncFunc:)to create aFuturefrom anasyncvalue. #1139 by RomanPodymov
- Added
- UINavigationController
- Added
pushViewController(_:hidesBottomBar:animated:)for hiding the bottom bar when pushing anyUIViewController. #1117 by imdkhairul
- Added
- UIButton
- Added
setBackgroundColor(_:for:)method for setting background color for the specified UI state. #1041 by TwizzyIndy - Added
imageForFocused,titleColorForFocused,titleForFocused,attributedTitleForFocusedto handle focused state. #1063 by Roman Podymov
- Added
- Array
- DefaultStringInterpolation
- Added
appendInterpolation(_:placeholder:predicate:)method for providing placeholder string if interpolated value isnilor the optional predicate closure returnsfalse. #1074 by Shiva Huang
- Added
- SFEdgeInsets
- Excluded type alias
SFEdgeInsetswhen targeting visionOS platform. #1126 by MarcoEidinger
- Excluded type alias
- String
- UIAlertController
- Excluded
show(animated:vibrate:completion:)when targeting visionOS platform. #1126 by MarcoEidinger
- Excluded
- UITabBar
- Fixed compilation error for
setColors(background:selectedBackground:item:selectedItem:)when targeting visionOS platform. #1126 by MarcoEidinger
- Fixed compilation error for
- URL
- URLRequest
- Added
method()to duplicate the request and modify the HTTP method (verb) for the request (i.e.: GET, POST, PUT) #1133 by Ricardo Rauber - Added
header(name:, value:)to duplicate the request and set a header with key and value. #1134 by Ricardo Rauber
- Added
- URLSession
- Added
dataSync(for:)to make requests synchronously. #1076 by Roman Podymov
- Added
- UIStackView
- UIButton:
- Add
.focusedtoUIButton.states. #1062 by Roman Podymov.
- Add
- Date
- Digest
- HKActivitySummary
- NotificationCenter
- Fixed warning in
observeOncethat about capture in sendable closure.
- Fixed warning in
- UINavigationBar
- String
- Sequence
- UIView
- Rename
shadowColor,shadowOffset,shadowOpacityandshadowRadiustolayerShadowColor,layerShadowOffset,layerShadowOpacityandlayerShadowRadiusto avoid naming collisions with subclasses properties defined in other modules e.g. UIKit. #897 by LucianoPAlmeida - Rename
borderColor,borderWidthandcornerRadiustolayerBorderColor,layerBorderWidth, andlayerCornerRadiusto avoid naming collisions with subclasses properties defined in other modules e.g. UIKit. #972 by Jayxiang
- Rename
- SCN3Vector
- Added
normalizedmethod, and basic division functions (SCNVector3 / scalar, andSCNVector3 /= scalar. #908 by thisIsTheFoxe
- Added
- Dictionary
- Added
pick(keys:)to pick part of a dictionary with specified keys. #911 by MaratIbragimov
- Added
- UIScrollView
- XCTest
- BinaryInteger
- Added
bytesandinit?(bytes:)to make it easier to work with bytes (as[UInt8]). #987 by thisIsTheFoxe
- Added
- FloatingPoint
- Collection
- UIViewController:
- String:
- Added
fullNSRange,range(from:),nsRange(from:)andsubscriptfor converting betweenRange<String.Index>andNSRange. #902 by guykogus - Overloaded Swift's 'contains' operator (
~=) forStringto check regex matching. #858 by VatoKo regexEscaped, which returns an escaped string for inclusion in a regex pattern- Added
matches(regex:options:)and the~= regexto check directly against NSRegularExpression. Also addedreplacingOccurrences(regex:template:options:searchRange:)as a more convenient way to replace NSRegularExpressions. #901 by gurgeous
- Added
- DispatchQueue:
- RangeReplaceableCollection:
- Sequence:
- Added
contains(_:)forHashableelements for performance improvement. #912 by guykogus - Added
first(where:equals:)to find the first element of the sequence with having property by given key path equals to given value. #836 by hamtiko - Added
last(where:equals:)to find the last element of the sequence with having property by given key path equals to given value. #838 by hamtiko
- Added
- SKNode:
- CGSize:
- WKWebView:
- HKActivitySummary:
- Added
isStandGoalMet,isExerciseTimeGoalMet, andisEnergyBurnedGoalMet. #875 by lhygilbert
- Added
- UIView:
- Added
masksToBounds(IBInspectable) extension. #877 by hamtiko - Added
loadFromNib(withClass:), which loads a UIView of a particular type from a nib file. #885 by gurgeous - Added
findConstraintfor finding an existing constraint. #886 by gurgeous - Added
widthConstraint,heightConstraint,leadingConstraint,trailingConstraint,topConstraint, andbottomConstraintfor finding specific constraints. #886 by gurgeous - Added
UIView.subviews(ofType:)extension which returns all the subviews of a given type recursively in the view hierarchy rooted on the view it its called. #993 by ashercoelho - Added
UIStackView.swap(_ view1:, _ view2:)extension which exchanges two views that are arranged in the stack. #989 by salahamassi - Added
addGradient(colors:locations:direction:)extension to apply gradient color. #1039 by Andy0570
- Added
- UIImage
- Added
averageColor, which calculates the average UIColor for an entire image. #884 by gurgeous - Added
withAlwaysOriginalTintColor(_:)returns a new version of the image with a tint color that uses the .alwaysOriginal rendering mode. #886 by [jayxiang][https://github.com/jayxiang]
- Added
- StringProtocol
- Measurement
- Added
.degrees(_:),arcMinutes(_:),arcSeconds(_:),radians(_:),gradians(_:)andrevolutions(_:)to conveniently initialize measurement with corresponding unit. #936 by Shiva Huang
- Added
- UITextField
- Added
addToolbar(items:height:)to add a toolbar to aUITextField. #954 by Randhir Kumar
- Added
- URL
- Added the
(unsafeString: String)initializer forURLas a more conveniently to construct unsafeURLs fromStringby jevonmao
- Added the
- MKMultiPoint
- Added
.coordinatesproperty, to return an array of coordinates for the providedMKMultiPoint. #990 by @rizwankce.
- Added
- NSAttributedString
- Added
Array.joined(separator:)to create a newNSAttributedStringby concatenating the elements of the sequence, adding the given separator between each element. #985 by Roman Podymov.
- Added
- UIButton
- Added
setAttributedTitleForAllStates,attributedTitleForDisabled,attributedTitleForHighlighted,attributedTitleForNormalandattributedTitleForSelectedfor convenient work with attributed strings. #1001 by Roman Podymov.
- Added
- Digest
- Added
hexStringto get a hexadecimal representation for all digest typed inCryptoKit(e.g.SHA216Digest,SHA512Digest,MD5Digest, ...). #1026 by Marco Eidinger.
- Added
- NSAttributedString:
- Color:
- Refactored
init(light:dark:)to remove deployment target version restrictions. #844 by VincentSit. - Use
enumto declare namespace instead of usingstruct. Thus private initializer is no longer needed. #927 by Shiva Huang - Add
init?(argbHexString:)to support the common ARGB format used in Android. #971 by yonat
- Refactored
- CAGradientLayer:
- UITextField:
- UIAlertController:
- Mark
showmethod as unavailable foriOSAppExtensiontargets. #918 by LucianoPAlmeida
- Mark
- UIRefreshControl:
- SKSpriteNode:
- Added
aspectFill(to:)to size SKSpriteNode with respect to aspect ratio. #490 by erikdrobne.
- Added
- Sequence:
- Marked
map(by:),compactMap(by:),filter(by:)as deprecated in favor use of Key Path expressions as functions feature in Swift 5.3. #862 by Roman Podymov.
- Marked
- UIDatePicker
- MKPolyline
- Removed
.coordinatesproperty, in favour of.coordinatesproperty fromMKMultiPoint. SinceMKPolylineextends fromMKMultiPointit should work fine. #990 by @rizwankce.
- Removed
- Collection
- CAGradientLayer:
- CAGradientLayer extensions inaccessible through internal level protection. #856 by Den Andreychuk.
- StringExtensions.swift:
- Fixed a bug: When the length of a string is 0, calling truncated method will crash. #866 by phil zhang
- Fixed
String.base64Decodedmaking it a safe decode by ignore non-base64 characters. #961 by Jayxiang
- UITextField
- UIImage
- UIView
- ColorExtension:
- Fixed a bug:
Color.FlatUIcan be initialized. by Shiva Huang - Fixed
Color.init?(hexString: String, transparency: CGFloat = 1)was not handling uppercase0Xin hex prefix #947 by Zero.D.Saber
- Fixed a bug:
- URLExtension
- 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(_:),isAffineandaffineTransform(). Also conforms toCodableandEquatable. #819 by guykogus
- CGAffineTransform:
- NotificationCenter:
- Optional:
- CoreLocation:
- Added
Array where Element: CLLocation extensionand addeddistance(unitLength:)function. #799 by trevorphillips - Added
isInRange(of:radius:unit:)to check if a location is within the radius of another location. #1095 by never-better
- Added
- Decodable:
- Added
init?(data:decoder:)to decodeDecodable(Codable) type models. #797 by Mustafa GUNES.
- Added
- CLVisit:
- Created
CLVisit Extensionand addedlocationproperty. #792 by trevorphillips
- Created
- EdgeInsets:
- Array:
- Added
sorted(like:keyPath:)to sort an array like another array based on a key path. #772 by MaxHaertwig.
- Added
- MKMapView:
- Added
zoom(to:meter:edgePadding:animated:)method to zoom multipleMKMapViewcoordinates. #723 by Mustafa GUNES.
- Added
- Dictionary:
- RangeReplaceableCollection:
- Added
removeDuplicates(keyPath:)for removing duplicate elements based on key path. #737 by Ilya Glushchuk. - Added
appendIfNonNil(_:)andappendIfNonNil(contentsOf:)methods that can append optional elements and sequences. #966 by jevonmao
- Added
- 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.
- Added
- String:
- 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 useStringandString.Rangein place ofNSStringandNSRangeto make the calls Swifter. #727 by guykogus.
- Added
- UIBarButtonItem:
- Added
flexibleSpaceandfixedSpace(width:)extensions to UIBarButtonItem to simplify the creation of spacers. #728 by MaxHaertwig.
- Added
- 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 aUIImagefrom a base-64String. #741 by @thisIsTheFoxe - Added
pngBase64String(),jpegBase64String(compressionQuality:)which return a Base 64Stringrepresentation of theUIImages PNG or JPEG data. #747 by Moritz Sternemann. - Added
init?(url:scale:)to initialize aUIImagewith a given url and scale factor. #753 by mmdock
- Added missing test for
- CAGradientLayer:
- Added
init(colors:locations:startPoint:endPoint:type:)convenience initializer. #726 by JayMehta97.
- Added
- Sequence:
- Added
sum(for:)to sum up anAdditiveArithmeticproperty, referenced byKeyPath, of all elements in a sequence. #736 by Moritz Sternemann. - Added
sorted(by:and:)andsorted(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.
- Added
- MutableCollection:
- Added
assignToAll(value:keyPath:)to assign given value to fieldkeyPathof every element in the collection. #759 by cyber-gh. - Added
sort(by:and:)andsort(by:and:and:)to sort a sequence based on multiple key paths. #796 by MaxHaertwig.
- Added
- KeyedDecodingContainer:
- Locale:
- URLRequest:
- SKProduct:
- Added
localizedPriceto get localized price of product. #781 by strawb3rryx7.
- Added
- CGRect
- Added property
center. #814 by qchenqizhi. - Added initializer
init(center:size:)to createCGRectwith center and size. #814 by qchenqizhi. - Added
resizing(to:anchor:)to createCGRectby resizing with anchor. #814 by qchenqizhi.
- Added property
- Collection:
- UIImage:
- UIImage:
- Sequence:
- NSAttributedString:
- Update
applying(attributes: [NSAttributedString.Key : Any], toRangesMatching pattern: String)to respondapplying(attributes: [NSAttributedString.Key : Any], toRangesMatching pattern: String, options: NSRegularExpression.Options = [])signature to support regular expression options. #791 by DimaZava
- Update
- UIButton:
- Refactored
centerTextAndImage(spacing:): now the image position can be above the text, by setting a new parameterimageAboveTexttotrue. #807 by qchenqizhi.
- Refactored
- String:
- Fixed build error occurring when building AppKit extensions for macCatalyst. #762 by MaxHaertwig.
- Fixed
String.base64Decodedmaking 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.
-
Array:
- Added
withoutDuplicates(keyPath:)for filtering duplicate elements based on key path. #704 by RomanPodymov.
- Added
-
Sequence:
- Added
withoutDuplicates(transform:)for remove duplicate elements based on condition in a sequence. #666 by saucym - Added
sorted(by:with:)to return sorted array from aSequencewith by a given keyPath using a compare function. #712 by LucianoPAlmeida
- Added
-
MutableCollection:
- Added
sort(by:with:)to sort aCollectionwith by a given keyPath using a compare function. #712 by LucianoPAlmeida
- Added
-
String
-
CGSize:
- Added
aspectRatio,maxDimension, andminDimensionproperties. #662 by MaxHaertwig.
- Added
-
SCNBox:
- Added
init(width:height:length:),init(sideLength:chamferRadius:),init(width:height:length:chamferRadius:material:),init(sideLength:chamferRadius:material:),init(width:height:length:chamferRadius:color:), andinit(sideLength:chamferRadius:color:)convenience initializers. #660 by MaxHaertwig.
- Added
-
SCNCapsule:
- Added
init(capDiameter:height),init(capRadius:height:material:),init(capDiameter:height:material:),init(capRadius:height:color:), andinit(capDiameter:height:color:)convenience initializers. #660 by MaxHaertwig.
- Added
-
SCNCone:
- Added
init(topDiameter:bottomDiameter:height),init(topRadius:bottomRadius:height:material:),init(topDiameter:bottomDiameter:height:material:),init(topRadius:bottomRadius:height:color:), andinit(topDiameter:bottomDiameter:height:color:)convenience initializers. #660 by MaxHaertwig.
- Added
-
SCNCylinder:
- Added
init(diameter:height),init(radius:height:material:),init(diameter:height:material:),init(radius:height:color:), andinit(diameter:height:color:)convenience initializers. #660 by MaxHaertwig
- Added
-
SCNGeometry:
- Added
boundingSizeproperty to get the size of the geometry's bounding box. #660 by MaxHaertwig.
- Added
-
SCNMaterial:
- Added
init(color:)convenience initializer. #660 by MaxHaertwig.
- Added
-
SCNPlane:
- Added
init(width:),init(width:height:material:),init(width:material:),init(width:height:color:), andinit(width:color:)convenience initializers. #660 by MaxHaertwig.
- Added
-
SCNShape:
- Added
init(path:extrusionDepth:material:)andinit(path:extrusionDepth:color:)convenience initializers. #660 by MaxHaertwig.
- Added
-
SCNSphere:
- Added
init(diameter:),init(radius:material:),init(radius:color:),init(diameter:material:), andinit(diameter:color:)convenience initializers. #660 by MaxHaertwig.
- Added
-
SCNVector3:
- Added
absoluteproperty to calculate the vector's components as absolute values. #660 by MaxHaertwig. - Added
lengthproperty to calculate the vector's length. #660 by MaxHaertwig.
- Added
-
UICollectionView:
-
Sequence:
-
UIBezierPath:
- Added
init(from:to:),init(points:),init(polygonWithPoints:),init(ovalOf:centered:)andinit(rectOf:centered:)convenience initializers. #659 by MaxHaertwig.
- Added
-
UIApplication:
- Refactored
queryValue(for:)extension for URL. #668 by LucianoPAlmeida.
- Refactored
-
Sequence:
- Array:
- Deprecated
sorted(by:ascending:)andsort(by:ascending:)in favor ofsorted(by:with:)andsort(by:with:)#712 by LucianoPAlmeida
- Deprecated
-
Character:
- Removed
isNumber,isLetter,isLowercased,isUppercasedandisWhiteSpacebecause the same properties are defined in the Swift standard library. #689 by RomanPodymov.
- Removed
-
Array:
-
UIApplication:
- Resolved an issue where
versionwould return the wrong Info.plist value. - Resolved an issue where
versionanddisplayNamewould return nil if localized.
- Resolved an issue where
-
UIImage:
- The size of rect can equal to the size of UIImage when using
cropped(to:)to crop UIImage. #679 by dirtmelon. scaled(toHeight:opaque:)andscaled(toWidth:opaque:)will now keep the original scale of UIImage. #703 by ShannonChou
- The size of rect can equal to the size of UIImage when using
-
UITableView:
- Swift 5.0 Support
- Updated the project to Xcode 10.2
- Removed unnecessary
publicstatements.
- Linux Support
- Support for Linux running Swift 5.0 using Swift Package Manager.
- UIApplication:
- Added
inferredEnvironmentto get current inferred app environment. by omaralbeik - Added
displayNameto get application name. by omaralbeik - Added
buildNumberto get application build number. by omaralbeik - Added
versionto get application version number. by omaralbeik
- Added
- Optional:
- Added
nonEmptyto get the collection only if it is not nill and not empty. by omaralbeik
- Added
- FileManager:
- UILabel:
- Added
init(text:style)to create aUILabelwith a text and font style. #607 by marcocapano
- Added
- UIViewController
- Added
presentPopover(_:sourcePoint:size:delegate:animated:completion:)method to quickly present aUIViewControlleras a popover. #593 by marcocapano
- Added
- Sequence:
- Added
duplicates()for getting the duplicated elements in a sequence. #605 by dylancfe15
- Added
- Date:
- Added
tomorrowcomputed property to get tomorrow's date avoiding callingadding(_:value:)function. (Completes PR #578) #587 by AlexeiGitH - Dictionary:
- Added
Dictionary[path:]subscript for deep fetching/setting nested values. #574 by @calebkleveter
- Added
- UIColor:
- Added
whatsAppcolor constant to social struct. #581 by staffler-xyz
- Added
- DispatchQueue:
- BidirectionalCollection:
- BinaryFloatingPointExtensions:
- UIActivity:
- Added
ActivityTypeconstants for iCloud Drive, WhatsApp, LinkedIn and XING. #580 by staffler-xyz
- Added
- MKMapView
- Added
register(annotationViewWithClass:),dequeueReusableAnnotationView(withClass:)anddequeueReusableAnnotationView(withClass:annotation)methods. #629 by staffler-xyz
- Added
- Character:
- Added more cases to
isEmoji. by omaralbeik
- Added more cases to
- String:
- Added more cases to
isEmoji. by omaralbeik - Made
camelize,latinize,reverse,slice,trim,truncate,urlDecode,urlEncode,padStart, andpadEndreturn adiscardableResultself. by omaralbeik
- Added more cases to
- Examples:
- StringProtocol:
- Removing Index constraint on
commonSuffixextension and improving performance and tests. #606 by LucianoPAlmeida.
- Removing Index constraint on
- RangeReplaceableCollection:
Arrayextensionskeep(while: ),take(while: )andskip(while:)are nowRangeReplaceableCollectionextensions. #634 by LucianoPAlmeida.
- Date:
- Fixed
yesterdaycomputed property to be calculated using Calendar.date(byAdding:to:) instead of date.addingTimeInterval(-86400) #641 by AlexeiGitH.
- Fixed
- UIImageView:
- Fixed
downloadfunction to useunowned self. by omaralbeik
- Fixed
- Installation:
- UIImage:
- Fixed
cropped(to:)size checking. #575 by ilyahal - Fixed
tint(_ color:, blendMode:)upside-down image. #639 by LucianoPAlmeida.
- Fixed
- NSAttributedString:
- Fixed
attributesproperty crash when the string is empty. #617 by LucianoPAlmeida.
- Fixed
- Date:
- Fixed
yesterdaycomputed property to be calculated using Calendar.date(byAdding:to:) instead of date.addingTimeInterval(-86400) #641 by AlexeiGitH. - Fixed
tomorrowcomputed property to be calculated using Calendar.date(byAdding:to:) instead of date.addingTimeInterval(86400) #642 by AlexeiGitH.
- Fixed
- SwifterSwift:
- Breaking Change Removed
SwifterSwiftby omaralbeik.
- Breaking Change Removed
- Collection:
- Removed
firstIndex(where: ),firstIndex(of:),lastIndex(where: ),lastIndex(of:)which are no longer needed. #637 by marcocapano
- Removed
- Date:
- Updated Travis to use the new
xcode10.2osx_image. - Added Fastlane to automate the releasing process for maintainers.
- Date
- Added
yesterdaycomputed property to quickly get yesterday's date to avoid callingadding(_:value:)function. #578 by AlexeiGitH
- Added
- UIView
- Added
ancestorView(where:)andancestorView(withClass:)to search for a view in the superviews. #560 by overovermind
- Added
- Fixed Cocoapods installation setting the correct Swift version
- CGVector
- Added
anglecomputed property to get the angle of the vector (in radians). #527 by moyerr - Added
magnitudecomputed 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
- Added
- UIRefreshControl:
beginRefresh(in tableView:, animated:, sendAction:)UIRefreshControl extension to begin refresh programmatically. #525 by ratulSharker
- Dictionary:
- Added
removeValueForRandomKey()to remove a value for a random key from a dictionary. #497 by MaxHaertwig. - Added
mapKeysAndValues(_:)to map aDictionaryinto aDictionarywith different (or same)KeyandValuetypes. #546 by guykogus - Added
compactMapKeysAndValues(_:)to map aDictionaryinto aDictionary, excludingnilresults, with different (or same)KeyandValuetypes. #546 by guykogus - Added
keys(forValue:)which returns an array of all keys that have the given value in dictionary. #561 by mauliksharma.
- Added
- RangeReplaceableCollection:
- Added
removeRandomElement()to remove a random element from a collection. #497 by MaxHaertwig.
- Added
- UIView
- Added
addGestureRecognizers(_:)which accepts an array ofUIGestureRecognizerto add multiple gesture recognizers to a view with one call. #523 by moyerr - Added
removeGestureRecognizers(_:)which accepts an array ofUIGestureRecognizerto remove multiple gesture recognizers from a view with one call. #523 by moyerr
- Added
- UIViewController
- Added
addChildViewController(_:toContainerView)to easily add child view controllers. Accepts aUIViewControllerand aUIViewto add the child's view to. - Added
removeViewAndControllerFromParentViewController()to remove aUIViewControllerfrom its parent.
- Added
- NSView
- Added
backgroundColorwhich allows to change backgroundColor of NSView #702 by RomanPodymov
- Added
- UIEdgeInsets
- Added
insetBy(top:),insetBy(left:),insetBy(bottom:),insetBy(right:),insetBy(horizontal:)andinsetBy(vertical:)to creates anUIEdgeInsetsbased 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
- Added
- 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.
- Added
- RangeReplaceableCollection
init(expression:count:)to create a collection of a given count initialized with an expression.#537 by LucianoPAlmeida.
- Optional:
- Data:
- URL
- 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 * CGSizeto return the multiplication of two CGSize. - Added operator
CGSize * CGFloatandCGFloat * CGSizeto return the multiplication of a CGSize and a CGFloat value. - Added operator
CGSize *= CGSizeto multiply a CGSize with another one. - Added operator
CGSize *= CGFloatto multiply a CGSize with a CGFloat value.
- Added operator
- UIImage:
- RangeReplaceableCollection:
rotate(by:)androtated(by:)array extensions now are more genericRangeReplaceableCollectionextensions. #512 by LucianoPAlmeida.removeFirst(where:)array extension now is more genericRangeReplaceableCollectionextensions. #516 by LucianoPAlmeida.
- RandomAccessCollection:
indices(of:)array extension now is more genericRandomAccessCollectionextensions. #516 by LucianoPAlmeida.
- UIView:
- UIImage:
- Fixed
scaled(toWidth:, with orientation:)andscaled(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
- Used RFC 5322 in
- String:
isEmailproperty has been renamed toisValidEmail.
- SKNode:
- Added
descendantsmethod to get an array of all descendants of an SKNode. #490 by oliviabrown9.
- Added
- Comparable:
- UIScrollView:
- UIGestureRecognizer:
- Character:
- Added
randomAlphanumeric()method to generate a random alphanumeric Character. #462 by oliviabrown9
- Added
- String:
- Added
firstCharacterUppercased()method to return a string with only the first character uppercased. #505 by happiehappie
- Added
- UITextView:
- Added
wrapToContent()method which will remove insets, offsets, paddings which lies within UITextView'sboundsandcontentSize. #458 by ratulSharker
- Added
- URL
- Added
deletingAllPathComponents()anddeleteAllPathComponents()to delete all path components from a URL. #441 by setoelkahfi. - Added
queryValue(for:)to get the value of a query key from a URL. #467 by jdisho.
- Added
- UITableView:
- Added
isValidIndexPath(_:)method to check whether given IndexPath is valid within UITableView. #441 by setoelkahfi. - Added
safeScrollToRow(at:at:animated:)method to safely scroll UITableView to the given IndexPath. #445 by setoelkahfi. - Fixed
lastSection, andindexPathForLastRowandindexPathForLastRow(inSection: 0)methods to get last section, get the lastIndexPath for section 0 if exists and get the lastIndexPath for a given section respectively . #694 by mohshin-shah.
- Added
- Optional:
- Added
isNilOrEmptyproperty to check whether an optional is nil or empty collection.
- Added
- UIWindow:
- Added
switchRootViewControllermethod to switch root view controller with animation. #494 by omaralbeik.
- Added
- Sequence
- Added
containsDuplicates()to check whether a sequence contains duplicates. #496 by MaxHaertwig. - Added
single(where:)to get the only element of a sequence that matches a given condition. #483 by andlang.
- Added
- UIStackView:
- Added
addArrangedSubviews(_ views: )to add an array of views to the end of the arrangedSubviews array. #501 by omaralbeik. - Added
removeArrangedSubviewsto remove all views in stack’s array of arranged subviews. #501 by omaralbeik.
- Added
- UIEdgeInsets
- Added
horizontalandverticalproperties. Alsoinit(inset:)andinit(horizontal: vertical:)initializers for convenience. #500 by LucianoPAlmeida.
- Added
- UITableView:
- UICollectionView:
- UIView:
- Breaking Change
firstResponderUIView extension is now a function and supports recursive find in the view hierarchy. #447 by LucianoPAlmeida.
- Breaking Change
- UIImage:
scaled(toWidth:, opaque:, with orientation:)andscaled(toHeight:, opaque:, with orientation:)now have an optional parameter for opaqueness. #446 by MaxHaertwig.
- Array/Collection/Sequence
- The conformance of
sum(),last(where:),reject(where:),count(where:),forEachReversed(),forEach(where:, body:),accumulate(initial:, next:),filtered(_:, map:)andcontains(_:)has been changed from Array to Sequence #470 by MaxHaertwig. - The conformance of
average(),firstIndex(where:),lastIndex(where:),indices(where:),forEach(slice:, body:),group(by:),firstIndex(of:)andlastIndex(of:)has been changed from Array to Collection #470 by MaxHaertwig.
- The conformance of
- Dictionary
- The
removeAll(keys:)changed its parameter keys to a genericSequenceinstead of anArray. #482 by LucianoPAlmeida.
- The
- Array
groupByKey(keyForValue:). #454 by @calebkleveter
- UIImage:
scaled(toWidth:, with orientation:)andscaled(toHeight:, with orientation:)were ignoring an image's scale. #446 by MaxHaertwig.init(color:size:)fixed to ensure thatUIGraphicsEndImageContextis always called afterUIGraphicsBeginImageContextWithOptions(_:_:_)#507 by guykogus
- Swift 4.1 / Xcode 9.3
- Added Swift 4.1 support.
- Linux Support:
- Updated all swift files to use Swift's 4.1
# if canImport(module)statement, which brings the project one step closer to first-class Linux support.
- Updated all swift files to use Swift's 4.1
- Sequence
- SignedInteger
- SignedNumeric
- String
- SwiftLint:
- reduced the number of disabled rules in .swiftlint.yml, please add
disableandenablestatements from now on when needed in code. - added SwiftLint to test targets to insure code style consistency across the project.
- reduced the number of disabled rules in .swiftlint.yml, please add
- SignedNumeric:
asLocaleCurrencynow returns an optional string.
- Array:
rotatemethod now returns adiscardableResult.shufflemethod now returns adiscardableResult.sort<T: Comparable>(by:, ascending:)method now returns adiscardableResult.keepmethod now returns adiscardableResult.
- UIStoryboard:
mainStoryboardproperty has been renamed tomain.
- Array:
- deprecated
popmethod in favor of Swift’spopLast. - deprecated
pushmethod in favor of Swift’sappend. - deprecated
swapmethod in favor of Swift’sswapAt. - deprecated
item(at index: Int)method in favor ofsubscript(safe:). duplicatesRemovedmethod has been renamed towithoutDuplicates.
- deprecated
- Bool:
- deprecated
toggledproperty, use!selfinstead. - deprecated
togglemethod, useself = !selfinstead.
- deprecated
- String
- Fixed UIView extension
addShadowwas not showing the shadow on view bug. #420 by LucianoPAlmeida.
- Fixed UIView extension
- MKPolyline
- Optional
- Added
.unwrapped(or:)method, to get the value wrapped by an optional or throw a custom error. #413 by @calebkleveter.
- Added
- UIButton
- Array
- Int
- added
roundToNearest(n:)to round an integer to the closest multiple of a given n. #381 by MaxHaertwig.
- added
- FileManager
- added
jsonFromFile(atPath path:, readingOptions:)to open a JSON file and serialize its content to a [String, Any]? instance with a provided path. #390 by jason-ingenuity. - added
jsonFromFile(withFilename filename:, at bundleClass:, readingOptions:)to open a JSON file and serialize its content to a [String, Any]? instance given a filename. #390 by jason-ingenuity.
- added
- Int
- StringProtocol
- added
commonSuffix(with:, options:)to get the longest common suffix of the receiver and a given string. #379 by MaxHaertwig.
- added
- UICollectionView
- added
register(nibWithCellClass:, at bundleClass:)method to be able to register a cell with custom nib just by its class name. #386 by jason-ingenuity.
- added
- UIFont
- added
boldanditalicto UIFont. #382 by MaxHaertwig.
- added
- UIImage
- added
withRoundedCorners(radius:)to round the corners of an image. The parameter radius is optional, the resulting image will be round if it is unspecified. #380 by MaxHaertwig.
- added
- UITableView
- added
register(nibWithCellClass:, at bundleClass:)method to be able to register a cell with custom nib just by its class name. #386 by jason-ingenuity.
- added
- URL
- added
queryParametersproperty to get the query parameters from a URL as a dictionary. #370 by nathanbacon. - added
thumbnail(fromTime:)to generate a thumbnail image from a given url. 410 by BennX.
- added
- UserDefaults
- added
object(type: with key: usingDecoder decoder:)method to be able to retrieve Codable objects from UserDefaults. #388 by jason-ingenuity. - added
set(codable: forKey key: usingEncoder encoder:)method to be able to store Codable objects from UserDefaults. #388 by jason-ingenuity.
- added
- String
- New UIStackView
- String
- Collection
- Fixed
randomItemcrash with empty array. #405 by LucianoPAlmeida.
- Fixed
- NSPredicate
- Added operator
!to return a new predicate formed by NOT-ing a given predicate. - Added operator
+to return a new predicate formed by AND-ing two given predicates. - Added operator
|to return a new predicate formed by OR-ing a two given predicates. - Added operator
-to return a new predicate formed by removing the argument from the second predicate. #345 by yycking.
- Added operator
- NSAttributedString
- Added
attributesproperty to get the attributes that apply to a simple NSAttributedString. #333 by nathanbacon. - Added
applying(attributes: , toRangesMatching: )function to return an attributed string with attributes applied to substrings matching the passed regex pattern by nathanbacon. - Added
applying(attributes: , toOccurrencesOf: )function to return an attributed string with attributes applied to substrings matching the passed string by nathanbacon.
- Added
- Array
- Added
sort(by: KeyPath)andsorted(by: KeyPath)to sort arrays based on Swift 4 keyPath. #343 by LucianoPAlmeida.
- Added
- String
- Added
loremIpsum(ofLength: )static function to return a lorem ipsum string. #318 by omaralbeik.
- Added
- UIDatePicker
- Added
textColorto get and set the text color of a UIDatePicker. #328 by omaralbeik.
- Added
- NSImage
- Added
write(to url: URL, fileType type: _, compressionFactor: _)to write NSImage to url. #320 by omaralbeik.
- Added
- Date
- Added
random(from: Date, upTo: Date) -> Datemethod that return radom date in in the specified range #336 by akuzminskyi. - Added
string(withFormat format: String)method to get a string from a date with the given format. - Added
init?(integerLiteral value: Int)initializer to create date object from Int literal. #342 by n0an.
- Added
- UIViewController
- Array
- Breaking Change
indexes(of:)has been renamed toindices(of:). #355 by Najdan shuffleandshuffledare no more constrained to Equatable. #327 by LucianoPAlmeida.
- Breaking Change
- Int
- UINavigationBar
- Fixed a bug where makeTransparent was keeping the background color. #344 by omaralbeik.
- Continuous Integration
- Fixed swiftlint warning in
NSImageExtensions.
- Fixed swiftlint warning in
- String
lengthis deprecated, use nativecountinstead.slicing(i:)is deprecated, usestring[safe: i]instead.slicing(from: to:)is deprecated, usestring[safe: start..<end].firstIndex(of:)is deprecated, use the nativesindex(of: Character)orrange(of: StringProtocol)instead.splitted(by:)is deprecated, use the nativesplit(separator: )instead.reversed() -> Stringis deprecated, use the Swift 4 newreversed() -> ReversedCollection<String>. #305 by LucianoPAlmeida.
- Date
- New String extensions
- added
padStart(length: with:)andpadEnd(length: with:)to pad the string to a length on the start or end. - added
paddingStart(length: with:)andpaddingEnd(length: with:)to return a padding string to a length on the start or end. #300 by LucianoPAlmeida
- added
- New NSImage extensions
- New Date extensions
- New Optional extensions
- New Calendar extensions
- added
numberOfDaysInMonthto get number of days in the month for a specified date. #311 by chaithanyaprathyush.
- added
- New Color tests
- added tests for
cgFloatComponents. #297 by stupergenius. - added
lighten(by percentage:)anddarken(by percentage:)methods to change the hue of a color. #325 by oettingerj.
- added tests for
- New CGColor tests
- New Date tests
- Updated Travis image to Xcode 9.1. #314 by kaphacius
- Removed cross references from extensions. #297 by stupergenius.
- Updated copyright headers to Copyright © 2017 SwifterSwift everywhere. #308 by camdeardorff.
- Date
- complete rewrite for most extensions. #309 by omaralbeik
- fixed a bug in
yearwhere setting year was resetting all smaller components to zero. - fixed a bug in
monthwhere setting month was resetting all smaller components to zero. - fixed a bug in
daywhere setting day was resetting all smaller components to zero. - fixed a bug in
hourwhere setting hour was resetting all smaller components to zero. - fixed a bug in
minutewhere setting minute was resetting all smaller components to zero. - fixed a bug in
secondwhere setting second was resetting all smaller components to zero. - added validation to setters for properties above.
- fixed the above bugs in
changingmethod as well. - fixed a bug where
quarterwas returning 1 always. - Added more tests to edge cases.
N/A
- Color
- Refactored duplicated code from
UIColorExtensionsandNSColorExtensionsintoColorExtensions. thanks to SD10. - Refactored duplicated tests from
UIColorExtensionsTestsandNSColorExtensionsTestsintoColorExtensionsTests. #260 by LeLuckyVint. - Add
cgFloatComponentsto get RGB components for a Color represented as CGFloat numbers (between 0 and 1) blendnow support NSColor as well.- Corrected some typos in README. #263 by nick3399.
- Refactored duplicated code from
- New String extensions
- Add
localized(comment:)to returns a localized string, with an optional comment for translators. #269 by MaxHaertwig.
- Add
- New NSPredicate extensions
- Add
notto returns a new predicate formed by NOT-ing the predicate. - Add
and(_ predicate: NSPredicate)to returns a new predicate formed by AND-ing the argument to the predicate. - Add
or(_ predicate: NSPredicate)to returns a new predicate formed by OR-ing the argument to the predicate. #273 by MaxHaertwig.
- Add
- New UILabel extensions
- Add
convenience init(text: String?)to initialize a UILabel with text. #271 by MaxHaertwig.
- Add
- New Bool extensions
- Add
randomto returns a random boolean value. #272 by MaxHaertwig.
- Add
- Continuous Integration
- Add macOS tests to travis-ci.
- Add calls to
swiftlintandpod lib lintin Travis #264 by calebkleveter.
- New SignedNumeric extensions tests
- Color
- Fixed a bug in
rgbComponents,shortHexString, andshortHexOrHexStringwhere an exception was raised when color is white or black. - Corrected a typo in
rgbComponents->rgbComponents
- Fixed a bug in
- Swift4 / Xcode9 🎉
- This version brings support for Swift4 and Xcode9. Looking for Swift3 / 3.2 ?
- UIColor
socialhas been renamed toSocialto match Apple Swift guidelinesmaterialhas been renamed toMaterialto match Apple Swift guidelinesflatUIhas been renamed toFlatUIto match Apple Swift guidelinescsshas been renamed toCSSto match Apple Swift guidelines
- NSColor
socialhas been renamed toSocialto match Apple Swift guidelinesmaterialhas been renamed toMaterialto match Apple Swift guidelinesflatUIhas been renamed toFlatUIto match Apple Swift guidelinescsshas been renamed toCSSto match Apple Swift guidelines
- SwiftLint
- Added SwiftLint to enforce Swift style and conventions.
- Danger
- New Date extensions
- New UIFont extensions
- added
monospaced -> UIFontmethod to get the current font as monospaced font. #250 by BennX, Monospaced Font explanation
- added
- UITableView
dequeueReusableCellnow returns an optionaldequeueReusableHeaderFooterViewnow returns an optional
- UICollectionView
dequeueReusableCellnow returns an optionaldequeueReusableSupplementaryViewnow returns an optional
- UIAlertController
- Added
preferredStyle: UIAlertControllerStyle = .alerttoinit from error.
- Added
- UIStoryboard
instantiateViewControllernow returns an optional.
- Continuous Integration
- Travis now builds
watchOStarget.
- Travis now builds
- SwifterSwift
didTakeScreenShotnow returns the notification, make sure to remove listener when you don't need it anymore.
- Swift 3.2
- Code has been updated to Swift 3.2; please use
v3.1.1if you are still using Swift 3 or Xcode 8
- Code has been updated to Swift 3.2; please use
- SwifterSwift
userDefaultsis deprecated, use Apple'sUserDefaults.standardinstead.object(forKey: String)is deprecated, use Apple'sUserDefaults.standard.object(forKey: _)instead.string(forKey: String)is deprecated, use Apple'sUserDefaults.standard.string(forKey: _)instead.integer(forKey: String)is deprecated, use Apple'sUserDefaults.standard.integer(forKey: _)instead.double(forKey: String)is deprecated, use Apple'sUserDefaults.standard.double(forKey: _)instead.data(forKey: String)is deprecated, use Apple'sUserDefaults.standard.data(forKey: _)instead.bool(forKey: String)is deprecated, use Apple'sUserDefaults.standard.bool(forKey: _)instead.array(forKey: String)is deprecated, use Apple'sUserDefaults.standard.array(forKey: _)instead.dictionary(forKey: String)is deprecated, use Apple'sUserDefaults.standard.dictionary(forKey: _)instead.float(forKey: String)is deprecated, use SwifterSwift'sUserDefaults.standard.float(forKey: _)instead.set(_ value: Any?, forKey: String)is deprecated, use Apple'sUserDefaults.standard.setValue(_, forKey: _)instead.
- Int
- Property
romanNumeralis now a method.
- Property
- String
- Property
linesis now a method. - Property
mostCommonCharacteris now a method. - Property
reversedis now a method. - Property
unicodeArrayis now a method. - Property
wordsis now a method. - Property
wordCountis now a method.
- Property
- UICollectionView
- Property
numberOfItemsis now a method.
- Property
- UITableView
- Property
numberOfRowsis now a method.
- Property
- UIViewController
- Removed
navigationBarthat was causing app to crash, thanks to drewpitchford for reporting in #243.
- Removed
- New Date extensions
- added
secondsSince(_ date: Date)method to get a number of seconds between two dates. - added
minutesSince(_ date: Date)method to get a number of minutes between two date. - added
hoursSince(_ date: Date)method to get a number of hours between two dates. - added
daysSince(_ date: Date)method to get a number of days between two date. - added
isInThisYearproperty to check if the date is in the current year. - added
isInThisMonthproperty to check if the date is in the current month. - added
isInThisWeekproperty to check if the date is in the current week.
- added
- New URLRequest extensions
- added
init?(urlString: String)fallible initializer create a URLRequest from URL string.
- added
- New UIWebView extensions
- added
loadURL(_ url: URL)method to load a URL. - added
loadURLString(_ urlString: String)method to load a URL string.
- added
- New UserDefaults extensions
- added
subscript(key: String)method to get values from UserDefaults using the [] operator. - added
float(forKey key: String)method to get a Float value from UserDefaults. - added
date(forKey key: String)method to get a Date value from UserDefaults.
- added
- Improved file structure, as in #236
- Improved README
- Removed unnecessary description in Installation section
- Updated List of All Extensions section to match the new file structure.
N/A
N/A
- New NSAttributedString extensions
- added
NSAttributedString + NSAttributedStringoperator to return a new appended NSAttributedString. - added
NSAttributedString += Stringoperator to append a string to a NSAttributedString. - added
NSAttributedString + Stringoperator to return a new appended NSAttributedString. #218 by @LucianoPAlmeida
- added
- New UIColor extensions
- added
flatUIstruct with all Flat UI colors. #213 by @tache - added
coreImageColorproperty to return CoreImage.CIColor. #213 by @tache - added
hsbaComponentsproperty to get components of hue, saturation, and brightness, and alpha. #213 by @tache - added
uIntproperty to get components of hue, saturation, and brightness, and alpha as UInt. #213 by @tache
- added
- New NSColor extensions
- New UIImage extensions
- New SignedNumber extensions. #224 by @omaralbeik
- moved
absfromFloatingPointExtensionsandIntExtensions - moved
isPositivefromFloatingPointExtensionsandIntExtensions - moved
isNegativefromFloatingPointExtensionsandIntExtensions - moved
stringfromFloatingPointExtensionsandIntExtensions - moved
asLocaleCurrencyfromFloatingPointExtensionsandIntExtensions
- moved
- New SignedInteger extensions. #224 by @omaralbeik
- moved
isEvenfromIntExtensions - moved
isOddfromIntExtensions - moved
digitsfromIntExtensions - moved
digitsCountfromIntExtensions - moved
timeStringfromIntExtensions - moved
gcd(of n)fromIntExtensions - moved
lcm(of n)fromIntExtensions
- moved
- Added
SwifterSwiftmodule_name to podspecs file to help solving conflicts with other 3rd party libraries. #226 by @omaralbeik - Moved missing examples from the old docs. #216 by @LucianoPAlmeida
- New
Intextensions - Improve sum & average extensions by not relying on reduce. #225 by @SD10
- New SVG logo in README! by @omaralbeik
- Fixed UISlider test by using XCTExpectation (#209). #229. by @LucianoPAlmeida
-
String
firstCharacterhas been renamed tofirstCharacterAsString. #208 by @omaralbeiklastCharacterhas been renamed tolastCharacterAsString. #208 by @omaralbeikfirstCharacterhas been renamed tofirstCharacterAsString. #208 by @omaralbeikfloathas been renamed tofloat(locale: Locale = .current). #208 by @omaralbeikdoublehas been renamed todouble(locale: Locale = .current). #208 by @omaralbeiksubscript(i: Int)has been renamed tosubscript(safe i: Int). #208 by @omaralbeiksubscript(range: CountableRange<Int>)has been renamed tosubscript(safe range: CountableRange<Int>). #208 by @omaralbeiksubscript(range: ClosedRange<Int>)has been renamed tosubscript(safe range: ClosedRange<Int>). #208 by @omaralbeikreplacing(_ substring: String, with newString: String)is deprecated, use Apple'sreplacingOccurrences(of: substring, with: newString)instead. #208 by @omaralbeikint8is deprecated, useInt8(string)instead. #208 by @omaralbeikint16is deprecated, useInt16(string)instead. #208 by @omaralbeikint32is deprecated, useInt32(string)instead. #208 by @omaralbeikint64is deprecated, useInt64(string)instead. #208 by @omaralbeikfloat32is deprecated, useFloat32(string)instead. #208 by @omaralbeikfloat64is deprecated, useFloat64(string)instead. #208 by @omaralbeik
-
UIColor
init(hex: Int, transparency: CGFloat = 1)is now a failable initializerinit?. #208 by @omaralbeikinit(red: Int, green: Int, blue: Int, transparency: CGFloat = 1)is now a failable initializerinit?. #208 by @omaralbeikredComponentis deprecated, use the newrgbComponents.redinstead. #208 by @omaralbeikgreenComponentis deprecated, use the newrgbComponents.greeninstead. #208 by @omaralbeikblueComponentis deprecated, use the newrgbComponents.blueinstead. #208 by @omaralbeik
- New String extensions
- added
cgFloat(locale: Locale = .current)to get CGFloat value from string. #208 by @omaralbeik - added
wordsto return an array of all words in a string. #208 by @omaralbeik - added
wordCountto get count of words in a string. #208 by @omaralbeik
- added
- New Int extensions
- added
countableRangeto get CountableRange 0..<Int. #208 by @omaralbeik - added
uIntto get UInt from Int. #208 by @omaralbeik
- added
- New Array extensions
- added
group(size:)to split in an array of slices of a size. #199. #208 by @LucianoPAlmeida - added
rotated(by:)to return a new rotated array by the given places. #207 by @LucianoPAlmeida - added
rotate(by:)to rotate the array by the given places. #207 by @LucianoPAlmeida
- added
- New UITextField extensions
- added
addPaddingLeftIcon(_ image: UIImage, padding: CGFloat)to add padding to the left of the textfield rect. #203 by @xingfuqiu - added
hasValidEmailto check if textFields text is a valid email format. #208 by @omaralbeik - added
textTypeto set textField for common text types like email addresses & passwords. #208 by @omaralbeik
- added
- New UIColor extensions
- added
rgbComponentsto get RGB components for a UIColor. #208 by @omaralbeik
- added
- Added usage examples in documentation for Foundation extensions. #208 by @omaralbeik
- Moved many duplicated extensions from
DoubleExtensionsandFloatExtensionsinto the newFloatingPointExtensions, this makes the code easier to maintain and brings support for other FloatingPoint types like CGFloat, Double32, ... #208 by @omaralbeik
- Fixed XCTAssertNotNil cannot handle optionals. #188. by @omaralbeik
- Fixed Tests are failing at non-english machine / Bug in String.double #187. by @omaralbeik
-
Documentation should be greatly improved and up to date now that we are using Jazzy to auto-generate docs! 🎉 #198 by @omaralbeik
-
SwifterSwift now supports subspecs to offer more control over imported extensions: #198 by @omaralbeik
- SwifterSwift/Foundation
- SwifterSwift/UIKit
- SwifterSwift/Cocoa
-
Arrayextensions now have throwing signatures. #170 by @LucianoPAlmeida -
New Array extensions
- added
groupByKeyto group the elements of the array by key in a dictionary. #181 by @LucianoPAlmeida - added
forEach(slice:body:)to iterate by specified slice size and call a closure. #194 by @LucianoPAlmeida
- added
-
New Dictionary extensions
- add
count(where:)to count dictionary elements where the condition returns true. #193 by @LucianoPAlmeida
- add
-
New String extensions
- added
isValidFileUrlto check if a String is a valid file URL. #175 by @LucianoPAlmeida - added
hasUniqueCharacters()method to check if string only contains unique characters. #195 by @FrankKair
- added
-
New Data extensions
- added
bytesto return data as an array of bytes. #171 by @LucianoPAlmeida
- added
-
New UITextField extensions
- Fixes asynchronous
iOS/tvOS/watchOSunit tests causing crashes. #191 by @LucianoPAlmeida
- New Array extensions
- added
removeAllpassing an array of items. - added
swapandsafeSwapextensions to swap to elements in an array. - new
firstIndexandlastIndexthat returns the (first or last) index where the condition is true. - new
indexesextension that return indexes where the condition is true. - new
allandnonethat checks if (all or none) of array elements match condition. - new
lastextension to find the last element that matches condition. - new
rejectextension to filter elements that not matches condition. - new
countextension to count elements that match condition. - new
forEachReversedextension to iterate over an array in reverse order. - new
accumulateextension to reduces an array while returning each interim combination. - new
forEachwith condition to a filtered interaction over the array. - new
keepextension to keep all elements that in order are until the condition is false. - new
takeextension that returns all elements that in order are until the condition is false. - new
skipextension that returns all elements that in order are after the condition is false. - new
filtered: mapextension to perform a map and filter operation in just one iteration.
- added
- New Character extensions
- added isLetter & isWhiteSpace extensions
- new lowercased extension to lower case the character
- new uppercased extension to upper case the character
- New Date extensions
- new
isInWeekdayextension to check if the date is within a weekday period
- new
- New Dictionary extensions
- new
removeAllextension to remove the values for all keys in an array. - new + operator to merge to dictionaries in a new one and += to merge one dictionary into another.
- new - operator to get a new dictionary with the values for all keys in an array removed and -= to remove the values for all keys in an array.
- new
- New String extensions
- new
matchesextension to check if the string matches a regex pattern.
- new
- New Locale extensions
- new posix property extension to convenience create the "en_US_POSIX" locale.
- New CLLocation extensions
- new
midLocationto find the half-way point along a great circle path between relative to another point. - new
bearingto calculate the bearing relative another location.
- new
- Fixes on wrong access levels for some extensions
- Improve NSAttributedStringExtensions extensions
- Fixes on implementations of some array extensions
- Fixes on some UIButtonExtensions
- Improvements on some Date extensions
- Improvements on some methods signatures based on Swift 3 API guidelines
- Improve code coverage.
- Improvements on documentation headers
This release has drastically increased test coverage: currently 92%. Areas affected are:
Foundation
- ArrayExtensions tests
- CharacterExtensions tests
- DateExtensions tests
- DictionaryExtensions tests
- StringExtensions tests
- LocaleExtensions tests
UIKit
- UIColorExtensions tests
- UIButtonExtensions tests
Cocoa
- CGSizeExtensions tests
- CGPointExtensions tests
- CLLocationExtensions tests
-
New Character extensions
- new * operator (repeat character n amount of times)
- added isLowercased & isUppercased extensions
-
New UICollectionView extensions
- new extensions to register/dequeue cells using UICollectionViewCell class as identifier
- new extensions to register/dequeue reusable views using UICollectionReusableView class as identifier
-
New UITableView extensions
- new extensions to register/dequeue cells using UITableViewCell class as identifier
- new extensions to register/dequeue header/footer views using UITableViewHeaderFooterView as identifier
-
New UIStoryboard extensions
- added extension to
instantiateViewControllerwith class as identifier - added extension get
mainStoryboard
- added extension to
-
New UIView extensions
- added quick getter and setter for frame’s X and Y values
-
New Array extensions
- added
safeSwapmethod as a fail-safe way to swap to elements in an array
- added
-
New NSView extensions
borderColor(IBInspectable)borderWidth(IBInspectable)cornerRadius(IBInspectable)heightshadowColor(IBInspectable)shadowOffset(IBInspectable)shadowOpacity(IBInspectable)shadowRadius(IBInspectable)sizewidthaddSubviews(subviews:)removeSubviews()
-
New Optional extensions
unwrapped(or:)unwrap an optional or provide default valuerun(block:)block to run if optional unwrapped is not nil
-
Improve UIImageView extensions
- fixes infinite recursive call in
blurred()method - removes superfluous error from
download(url:)method completion block
- fixes infinite recursive call in
-
Replace deprecated
M_PIwith.pi -
Fixes wrong implementation of -=
CGPointoperator -
Improve Array extensions
- properties with O(n) or higher complexity have been changed to methods
- reduced shuffle method complexity by using Fisher-Yates algorithm and is now completely random
removeDuplicatesrenamed toduplicatesRemoved.- remove generic constraint on
firstIndex(of:)andlastIndex(of:)
-
Improve String extensions
-
Improve Date extensions
-
Improve Data extensions
-
Improve Dictionary extensions
This release has drastically increased test coverage: currently 88%. Areas affected are:
Foundation
- CharacterExtensions tests
- StringExtensions tests
- ArrayExtensions tests
- IntExtensions tests
- DateExtensions tests
- DataExtensions tests
- DoubleExtensions tests
- FloatExtensions tests
- CGFloatExtensions tests
- CGPointExtensions tests
UIKit
- UIColorExtensions tests
- UIAlertControllerExtensions tests
- UIBarButtonItemExtensions tests
- UIButtonExtensions tests
- UITextViewExtensions tests
- UISegmentedControlExtensions tests
- UINavigationControllerExtensions tests
- UINavigationBarExtensions tests
- UINavigationItemExtensions tests
- UISliderExtensions tests
- UITableViewExtensions tests
- UICollectionViewExtensions tests
- UIViewControllerExtensions tests
- UIStoryboardExtensions tests
- UITextFieldExtensions tests
- UIViewExtensions tests
- UIImageExtensions tests
Cocoa
- NSColorExtensions tests
- NSViewExtensions tests
- Major bug fixes in DateExtensions.
- New Tests.
Fixed Cocoapods.
This is the biggest update since v1.3! With over 100 new extensions, improved Cocoa support, new tests, and many minor bug fixes.
- CGColorExtensions
- NSColorExtensions
- URLExtensions
- StringExtensions
- length: Number of characters in string.
- isValidSchemedUrl: Check if string is a valid schemed URL.
- UIImageExtensions:
- original: UIImage with .alwaysOriginal rendering mode.
- template: UIImage with .alwaysTemplate rendering mode.
- UISearchBarExtensions:
- clear: Clear text.
- UITextFieldExtensions:
- clear: Clear text.
- StringExtensions:
- trimmed
- copyToPasteboard
- truncated
- SwifterSwift
- isInTestFlight
- UIColorExtensions:
- shortHexString
- complementary
- Improved initializers
- StringExtensionsTests
- NSAttributedStringExtensionsTests
- UIColorExtensionsTests
- DateExtensionsTests
- CharacterExtensionsTests
Added project to CodeCov for better code coverage visualization.
General bug fixes and improvements.
###watchOS Support: Thanks to Paweł Urbanek for his great work adding watchOS target!
###tvOS Support: Thanks to Paweł Urbanek for his great work adding tvOS target!
###UICollectionViewExtensions:
- Fixed a bug in indexPathForLastItem.
- Renamed indexPathForLastItem(in section: Int) to indexPathForLastItem(inSection section: Int) to match Apple naming conventions
###UITableViewExtensions:
- Fixed a bug in indexPathForLastRow.
- Renamed indexPathForLastRow(in section: Int) to indexPathForLastRow(inSection section: Int) to match Apple naming conventions
##StringExtensions:
- Fixed a bug in count(of string: String, caseSensitive: Bool)
- Added slicing(from i: Int, length: Int): Sliced string from a start index with length.
- Added slice(from i: Int, length: Int): Slice given string from a start index with length (if applicable).
- Added slicing(from start: Int, to end: Int): Sliced string from a start index to an end index.
- Added slice(from start: Int, to end: Int): Slice given string from a start index to an end index (if applicable).
- Added slicing(at i: Int): Sliced string from a start index.
- Added slice(at i: Int): Slice given string from a start index (if applicable).
##StringExtensionsTests:
- Added tests for count(of string: String, caseSensitive: Bool)
- Added tests for slicing methods
##Contributing:
- Added Releases Flow
- Updated Adding new Extensions
##Misc:
- Introduced new releases Flow
Thanks to Paweł Urbanek and Michael
###CollectionExtensions:
- Added subscript (safe index: Index). Thanks to Sai Ram Kotha
###UIColorExtensions:
- Added complementary
- Added init?(complementaryFor color: UIColor)
Thanks to matt
###SwifterSwift:
- Added isInTestFlight
###DateExtensions:
- Added enum DayNameStyle.
- Added enum MonthNameStyle.
- Added isInYesterday.
- Added isInTomorrow.
- Added nearestHour.
- Added dayName(ofStyle style: DayNameStyle).
- Added monthName(ofStyle style: MonthNameStyle).
###UISearchBarExtensions:
- Added trimmedText.
###UIColorExtensions:
- Added cssColors.
- Added init?(hexString: String, transparency: CGFloat).
- Added shortHexString.
- Added shortHexOrHexString.
###StringExtensions:
- Added subscript(i: Int).
- Added subscript(range: CountableRange).
- Added subscript(range: ClosedRange).
- Swift Package Manager support
- Extension moved to Source directory; tests moved to Tests directory for a cleaner structure
###CollectionExtensions:
- Added forEachInParallel. Thanks to Siarhei Fiedartsou for contributing.
###TableViewExtensions:
- Added reloadData(_ completion: () -> Void).
###CollectionViewExtensions:
- Added reloadData(_ completion: () -> Void).
###UIButtonExtensions:
- Refactored setForAllStates methods code. Thanks to Ronan Rodrigo Nunes
###Misc.
- Fixed typos in README.
###DateExtensions:
- Changed nearestHourQuarter to nearestQuarterHour. Thanks to Robert Nix for reporting.
- Updated initializers to be optional.
###UITabBarExtensions:
- fixed selected color in setColors method.
###Tests
- Updated tests. Thanks to Siarhei Fiedartsou for updating.
###UIViewExtensions:
- Fixed bugs in fadeIn, fadeOut and rotate(byAngle) methods. Thanks to bastianschilbe for reporting.
- Removed isVisible property since it was causing many problems and not working correctly.
- Added parentViewController property to return view's parent view controller.
Fixed a bug in DateExtensinos where the year was not set correctly. Thanks to songhailiang you for reporting this bug.
- func addConstraints(withFormat: String, views: UIView...): Add Visual Format constraints
- func fillToSuperview(): Anchor all sides of the view into it's superview
- func anchor(top: NSLayoutYAxisAnchor?, left: NSLayoutXAxisAnchor?, bottom: NSLayoutYAxisAnchor?, right: NSLayoutXAxisAnchor?, topConstant: CGFloat, leftConstant: CGFloat, bottomConstant: CGFloat, rightConstant: CGFloat, widthConstant: CGFloat, heightConstant: CGFloat) -> [NSLayoutConstraint]: Add anchors from any side of the current view into the specified anchors and returns the newly added constraints.
- func anchorCenterXToSuperview(withConstant: CGFloat): Anchor center X into current view's superview with a constant margin value.
- anchorCenterYToSuperview(constant: CGFloat): Anchor center Y into current view's superview with a constant margin value.
- func anchorCenterSuperview(): Anchor center X and Y into current view's superview
- kFormatted: String formatted for values over ±1000 (example: 1k, -2k, 100k, 1kk, -5kk..)
Thanks to Jonathan Bijos & zzjzz9266a for adding new extensions.
Added CollectionViewExtensions
- removed duplicated contains a method
- use of reducing to remove duplicates (Thanks to sairamkotha)
This version adds more than 90 new extensions making it the widest extensions library available online for Swift 3 with more than 360 properties and methods for more than 35 type. This is the biggest update since library launch! We're so excited 🤓
Here are some changes:
- Updated some properties and methods names to follow Swift API Design Guidelines.
- Added default values to methods parameters (where possible).
- All units documentation has been re-written in Xcode,
- Now you see "SwifterSwift: " at the beginning of description to know the source of the extension while writing your code.
- All method parameters and return types have been documented in Xcode as well.
- All extensions documentation has been re-written in Wiki, separating properties from methods in different tables.
- All extensions files re-organized in separate extensions based on type (properties, methods, initializers, ..)
- Fixed some bugs where some extensions were not public.
- New section explaining how to add new extensions in Contributing Guidelines
- And finally: new logo
- UIColorExtensions:
- struct material: get Google material palette colors with ease
- UIColorExtensions:
- struct socialColors -> struct social
-
ConvenienceExtensions:
- func string(forKey: String): Get a string from UserDefaults
- func integer(forKey: String): Get an integer from UserDefaults
- func double(forKey: String): Get a double from UserDefaults
- func float(forKey: String): Get a float from UserDefaults
- func data(forKey: String): Get a data from UserDefaults
- func bool(forKey: String): Get a bool from UserDefaults
- func array(forKey: String): Get an array from UserDefaults
- func dictionary(forKey: String): Get a dictionary from UserDefaults
-
StringExtensions:
- func toDate(withFormat format: String): Return Date value from string of date format (if applicable).
- var toURL: Return URL from string (if applicable).
-
UIAlertControllerExtensions:
- addAction(title, style, isEnabled, handler): Add an action to Alert.
- addTextField(text, placeholder, editingChangedTarget, editingChangedSelector): Add a text field to Alert.
-
UINavigationBarExtensions:
- func setColors(background, text): Set Navigation Bar background and text colors.
-
ConvenienceExtensions:
- var deviceHeight -> var screenHeight
- var deviceWidth -> var screenWidth
-
ArrayExtensions:
- func removeAll(item: Element) -> func removeAll(_ item: Element))
-
DateExtensions:
- func add(component: Calendar.Component, value: Int) -> add(_ component: Calendar.Component, value: Int)
- func adding(component: Calendar.Component, value: Int) -> adding(_ component: Calendar.Component, value: Int)
- func changing(component: Calendar.Component, value: Int) -> changing(_ component: Calendar.Component, value: Int)
- func isIn(current: Calendar.Component) -> isInCurrent(_ component: Calendar.Component)
-
StringExtensions:
- func contain(string: String, caseSensitive: Bool) -> func contain(_ string: String, caseSensitive: Bool)
- func lines() -> var lines
- static func random(of length: Int) -> static func random(ofLength: Int)
- func replace(string: String, with: String) -> func replace(_ substring: String, with: String)
- func truncate(to length: Int, trailing: String?) -> func truncate(toLength: Int, trailing: String?)
- func truncated(to length: Int, trailing: String? = "...") -> func truncated(to length: Int, trailing: String?)
-
UIButtonExtensions:
- func imageForAllStates(image: UIImage) -> func setImageForAllStates(_ image: UIImage)
- func titleColorForAllStates(color: UIColor) -> func setTitleColorForAllStates(_ color: UIColor)
- func titleForAllStates(title: String) -> func setTitleForAllStates(_ title: String)
-
UIColorExtensions:
- init(netHex:Int) -> init(hex:Int, transparency: CGFloat = 1)
-
UIImageExtensions:
- func scaledToHeight(height: CGFloat, with orientation: UIImageOrientation?) -> scaled(toHeight: CGFloat, with orientation: UIImageOrientation?)
- func scaledToWidth(width: CGFloat, with orientation: UIImageOrientation?) -> scaled(toWidth: CGFloat, with orientation: UIImageOrientation?)
-
UIImageViewExtensions:
- func download(fromUrl: String?, contentMode: UIViewContentMode, placeHolder: UIImage?)) -> download(from: URL?, contentMode: UIViewContentMode, placeHolder: UIImage?, completionHandler: ((UIImage?, Error?) -> Void)?)
-
UISliderExtensions:
- func setValue(value: Float, animated: Bool, duration: TimeInterval, completion: (() -> Void)? = nil) -> func setValue(_ value: Float, animated: Bool, duration: TimeInterval, completion: (() -> Void)?)
-
UITableViewExtensions:
- var totalRows -> var numberOfRows
-
UITextFieldExtensions:
- func setPlaceHolderTextColor(color: UIColor) -> func setPlaceHolderTextColor(_ color: UIColor)
-
UIViewExtensions:
- func loadFromNibNamed(nibNamed: String, bundle : Bundle?) -> func loadFromNib(named: String, bundle : Bundle?)
- StringExtensions:
- var locale
UISearchBarExtensions:
- textField: Return the text field inside search bar
UITextFieldExtensions:
- setPlaceHolderTextColor(color): Change place holder text color
- leftViewTintColor: Left view tint color
- rightViewTintColor: Right view tint color
UINavigationItemExtensions:
- replaceTitle(with image): Replace title with an image in naivgation item
UITabBarExtensions:
- setColors(background, selectedBackground, item, selectedItem): Change UITabBar colors
UIImageExtensions:
- filled(withColor): Return image filled with color
- init(color, size): Create image from color and size
UITextViewExtensions:
- scrollToBottom(): Scroll to the bottom of text view
- scrollToTop(): Scroll to the top of text view
UISegmentedControlExtensions:
- segmentTitles: Segments titles
- segmentImages: Segments images
UISliderExtensions:
- setValue(value, animated, duration, completion): Set slide bar value with completion handler
UIAlertControllerExtensions:
- show(vibrate): Added optional vibration while presenting the alert
IntExtensions:
- asLocaleCurrency: Return string with number and current locale currency
FloatExtensions:
- asLocaleCurrency: Return string with number and current locale currency
DoubleExtensions:
- asLocaleCurrency: Return string with number and current locale currency
StringExtensions:
- Fixed a bug in toDouble, toFloat, toFloat32, toFloat64 where number is not calculated if not in English
DateExtensions:
- adding(component, value): Return date by adding a component
- nearestHourQuarter: Return the nearest quarter to date
- nearestHalfHour: Return nearest half hour to date
- changing(component, value): Return date by changing a component
- Fixed a bug in nearestFiveMinutes, nearestTenMinutes where date was always rounded always to next 5, 10 mins
UILabelExtensions:
- requiredHeight: Return required height for a label
UIImageViewExtensions:
- blur(withStyle: UIBlurEffectStyle): Make image view blurry
- blurred(withStyle: UIBlurEffectStyle): Return a blurred version of an image view
UINavigationControllerExtensions:
- makeTransparent(withTint: UIColor): Make navigation controller's navigation bar transparent
UINavigationBarExtensions:
- makeTransparent(withTint: UIColor): Make navigation controller's navigation bar transparent
UITextFieldExtensions:
- trimmedText: Return text with no spaces or new lines in beginning and end
UIViewExtensions:
- addShadow(ofColor, radius, offset, opacity): /// Add shadow to view
UIImageExtensions:
- filled(withColor): Return image filled with color
DateExtensions:
- nearestFiveMinutes: Return nearest five minutes to date
- nearestTenMinutes: Return nearest ten minutes to date
UIViewExtensions:
- shake: Completion handler added to shake function