The changelog for SwifterSwift. Also see the releases on GitHub.
-String:
- Overloaded Swift's 'contains' operator (
~=
) forString
to check regex matching. #858 by VatoKo -DispatchQueue: - Added
asyncAfter(delay:qos:flags:execute:)
method to use it more conveniently without typing unnecessary.now() + delay
. #859 by VatoKo - RangeReplaceableCollection:
- Sequence:
- SKNode:
- CGSize:
- WKWebView:
- NSAttributedStringExtensions.swift:
- Color:
- Refactored
init(light:dark:)
to remove deployment target version restrictions. #844 by VincentSit.
- Refactored
- CAGradientLayerExtensions.swift:
- CAGradientLayer extensions inaccessible through internal level protection. #856 by Den Andreychuk.
- 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
andaffineTransform()
. Also conforms toCodable
andEquatable
. #819 by guykogus
- CGAffineTransform:
- NotificationCenter:
- Optional:
- CoreLocation:
- Added
Array where Element: CLLocation extension
and addeddistance(unitLength:)
function. #799 by trevorphillips
- Added
- Decodable:
- Added
init?(data:decoder:)
to decodeDecodable
(Codable) type models. #797 by Mustafa GUNES.
- Added
- CLVisit:
- Created
CLVisit Extension
and addedlocation
property. #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 multipleMKMapView
coordinates. #723 by Mustafa GUNES.
- Added
- Dictionary:
- RangeReplaceableCollection:
- Added
removeDuplicates(keyPath:)
for removing duplicate elements based on key path. #737 by Ilya Glushchuk.
- 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 useString
andString.Range
in place ofNSString
andNSRange
to make the calls Swifter. #727 by guykogus.
- Added
- UIBarButtonItem:
- Added
flexibleSpace
andfixedSpace(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 aUIImage
from a base-64String
. #741 by @thisIsTheFoxe - Added
pngBase64String()
,jpegBase64String(compressionQuality:)
which return a Base 64String
representation of theUIImage
s PNG or JPEG data. #747 by Moritz Sternemann. - Added
init?(url:scale:)
to initialize aUIImage
with 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 anAdditiveArithmetic
property, 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 fieldkeyPath
of 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
localizedPrice
to get localized price of product. #781 by strawb3rryx7.
- Added
- CGRect
- Added property
center
. #814 by qchenqizhi. - Added initializer
init(center:size:)
to createCGRect
with center and size. #814 by qchenqizhi. - Added
resizing(to:anchor:)
to createCGRect
by 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 parameterimageAboveText
totrue
. #807 by qchenqizhi.
- Refactored
- String:
- 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.
-
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 aSequence
with by a given keyPath using a compare function. #712 by LucianoPAlmeida
- Added
-
MutableCollection:
- Added
sort(by:with:)
to sort aCollection
with by a given keyPath using a compare function. #712 by LucianoPAlmeida
- Added
-
String
-
CGSize:
- Added
aspectRatio
,maxDimension
, andminDimension
properties. #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
boundingSize
property 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
absolute
property to calculate the vector's components as absolute values. #660 by MaxHaertwig. - Added
length
property 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
,isUppercased
andisWhiteSpace
because the same properties are defined in the Swift standard library. #689 by RomanPodymov.
- Removed
-
Array:
-
UIApplication:
- Resolved an issue where
version
would return the wrong Info.plist value. - Resolved an issue where
version
anddisplayName
would 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
public
statements.
- Linux Support
- Support for Linux running Swift 5.0 using Swift Package Manager.
- UIApplication:
- Added
inferredEnvironment
to get current inferred app environment. by omaralbeik - Added
displayName
to get application name. by omaralbeik - Added
buildNumber
to get application build number. by omaralbeik - Added
version
to get application version number. by omaralbeik
- Added
- Optional:
- Added
nonEmpty
to get the collection only if it is not nill and not empty. by omaralbeik
- Added
- FileManager:
- UILabel:
- Added
init(text:style)
to create aUILabel
with a text and font style. #607 by marcocapano
- Added
- UIViewController
- Added
presentPopover(_:sourcePoint:size:delegate:animated:completion:)
method to quickly present aUIViewController
as a popover. #593 by marcocapano
- Added
- Sequence:
- Added
duplicates()
for getting the duplicated elements in a sequence. #605 by dylancfe15
- Added
- Date:
- Added
tomorrow
computed 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
whatsApp
color constant to social struct. #581 by staffler-xyz
- Added
- DispatchQueue:
- BidirectionalCollection:
- BinaryFloatingPointExtensions:
- UIActivity:
- Added
ActivityType
constants 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
, andpadEnd
return adiscardableResult
self. by omaralbeik
- Added more cases to
- Examples:
- StringProtocol:
- Removing Index constraint on
commonSuffix
extension and improving performance and tests. #606 by LucianoPAlmeida.
- Removing Index constraint on
- RangeReplaceableCollection:
Array
extensionskeep(while: )
,take(while: )
andskip(while:)
are nowRangeReplaceableCollection
extensions. #634 by LucianoPAlmeida.
- Date:
- Fixed
yesterday
computed property to be calculated using Calendar.date(byAdding:to:) instead of date.addingTimeInterval(-86400) #641 by AlexeiGitH.
- Fixed
- UIImageView:
- Fixed
download
function 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
attributes
property crash when the string is empty. #617 by LucianoPAlmeida.
- Fixed
- Date:
- Fixed
yesterday
computed property to be calculated using Calendar.date(byAdding:to:) instead of date.addingTimeInterval(-86400) #641 by AlexeiGitH. - Fixed
tomorrow
computed property to be calculated using Calendar.date(byAdding:to:) instead of date.addingTimeInterval(86400) #642 by AlexeiGitH.
- Fixed
- SwifterSwift:
- Breaking Change Removed
SwifterSwift
by 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.2
osx_image. - Added Fastlane to automate the releasing process for maintainers.
- Date
- Added
yesterday
computed 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
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
- Added
- Dictionary:
- Added
removeValueForRandomKey()
to remove a value for a random key from a dictionary. #497 by MaxHaertwig. - Added
mapKeysAndValues(_:)
to map aDictionary
into aDictionary
with different (or same)Key
andValue
types. #546 by guykogus - Added
compactMapKeysAndValues(_:)
to map aDictionary
into aDictionary
, excludingnil
results, with different (or same)Key
andValue
types. #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 ofUIGestureRecognizer
to add multiple gesture recognizers to a view with one call. #523 by moyerr - Added
removeGestureRecognizers(_:)
which accepts an array ofUIGestureRecognizer
to 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 aUIViewController
and aUIView
to add the child's view to. - Added
removeViewAndControllerFromParentViewController()
to remove aUIViewController
from its parent.
- Added
- NSView
- Added
backgroundColor
which 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 anUIEdgeInsets
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
- 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 * CGSize
to return the multiplication of two CGSize. - Added operator
CGSize * CGFloat
andCGFloat * 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.
- Added operator
- UIImage:
- RangeReplaceableCollection:
rotate(by:)
androtated(by:)
array extensions now are more genericRangeReplaceableCollection
extensions. #512 by LucianoPAlmeida.removeFirst(where:)
array extension now is more genericRangeReplaceableCollection
extensions. #516 by LucianoPAlmeida.
- RandomAccessCollection:
indices(of:)
array extension now is more genericRandomAccessCollection
extensions. #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:
isEmail
property has been renamed toisValidEmail
.
- SKNode:
- Added
descendants
method 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'sbounds
andcontenSize
. #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
, andindexPathForLastRow
andindexPathForLastRow(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
isNilOrEmpty
property to check whether an optional is nil or empty collection.
- Added
- UIWindow:
- Added
switchRootViewController
method 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
removeArrangedSubviews
to remove all views in stack’s array of arranged subviews. #501 by omaralbeik.
- Added
- UIEdgeInsets
- Added
horizontal
andvertical
properties. Alsoinit(inset:)
andinit(horizontal: vertical:)
initializers for convenience. #500 by LucianoPAlmeida.
- Added
- UITableView:
- UICollectionView:
- UIView:
- Breaking Change
firstResponder
UIView 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 paramenter keys to a genericSequence
instead 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 thatUIGraphicsEndImageContext
is 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
disable
andenable
statements 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:
asLocaleCurrency
now returns an optional string.
- Array:
rotate
method now returns adiscardableResult
.shuffle
method now returns adiscardableResult
.sort<T: Comparable>(by:, ascending:)
method now returns adiscardableResult
.keep
method now returns adiscardableResult
.
- UIStoryboard:
mainStoryboard
property has been renamed tomain
.
- Array:
- deprecated
pop
method in favor of Swift’spopLast
. - deprecated
push
method in favor of Swift’sappend
. - deprecated
swap
method in favor of Swift’sswapAt
. - deprecated
item(at index: Int)
method in favor ofsubscript(safe:)
. duplicatesRemoved
method has been renamed towithoutDuplicates
.
- deprecated
- Bool:
- deprecated
toggled
property, use!self
instead. - deprecated
toggle
method, useself = !self
instead.
- deprecated
- String
- Fixed UIView extension
addShadow
was 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
bold
anditalic
to 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
queryParmeters
property 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
randomItem
crash 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
attributes
property 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
textColor
to 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) -> Date
method 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 shuffle
andshuffled
are 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
length
is deprecated, use nativecount
instead.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() -> String
is 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
numberOfDaysInMonth
to 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
year
where setting year was resetting all smaller components to zero. - fixed a bug in
month
where setting month was resetting all smaller components to zero. - fixed a bug in
day
where setting day was resetting all smaller components to zero. - fixed a bug in
hour
where setting hour was resetting all smaller components to zero. - fixed a bug in
minute
where setting minute was resetting all smaller components to zero. - fixed a bug in
second
where setting second was resetting all smaller components to zero. - added validation to setters for properties above.
- fixed the above bugs in
changing
method as well. - fixed a bug where
quarter
was returning 1 always. - Added more tests to edge cases.
N/A
- Color
- Refactored duplicated code from
UIColorExtensions
andNSColorExtensions
intoColorExtensions
. thanks to SD10. - Refactored duplicated tests from
UIColorExtensionsTests
andNSColorExtensionsTests
intoColorExtensionsTests
. #260 by LeLuckyVint. - Add
cgFloatComponents
to get RGB components for a Color represented as CGFloat numbers (between 0 and 1) blend
now 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
not
to 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
random
to returns a random boolean value. #272 by MaxHaertwig.
- Add
- Continuous Integration
- Add macOS tests to travis-ci.
- Add calls to
swiftlint
andpod lib lint
in Travis #264 by calebkleveter.
- New SignedNumeric extensions tests
- Color
- Fixed a bug in
rgbComponents
,shortHexString
, andshortHexOrHexString
where an exception was raised when color is white or black. - Corrected a typo in
rgbComponenets
->rgbComponents
- Fixed a bug in
- Swift4 / Xcode9 🎉
- This version brings support for Swift4 and Xcode9. Looking for Swift3 / 3.2 ?
- UIColor
social
has been renamed toSocial
to match Apple Swift guidelinesmaterial
has been renamed toMaterial
to match Apple Swift guidelinesflatUI
has been renamed toFlatUI
to match Apple Swift guidelinescss
has been renamed toCSS
to match Apple Swift guidelines
- NSColor
social
has been renamed toSocial
to match Apple Swift guidelinesmaterial
has been renamed toMaterial
to match Apple Swift guidelinesflatUI
has been renamed toFlatUI
to match Apple Swift guidelinescss
has been renamed toCSS
to match Apple Swift guidelines
- SwiftLint
- Added SwiftLint to enforce Swift style and conventions.
- Danger
- New Date extensions
- New UIFont extensions
- added
monospaced -> UIFont
method to get the current font as monospaced font. #250 by BennX, Monospaced Font explanation
- added
- UITableView
dequeueReusableCell
now returns an optionaldequeueReusableHeaderFooterView
now returns an optional
- UICollectionView
dequeueReusableCell
now returns an optionaldequeueReusableSupplementaryView
now returns an optional
- UIAlertController
- Added
preferredStyle: UIAlertControllerStyle = .alert
toinit from error
.
- Added
- UIStoryboard
instantiateViewController
now returns an optional.
- Continuous Integration
- Travis now builds
watchOS
target.
- Travis now builds
- SwifterSwift
didTakeScreenShot
now 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.1
if you are still using Swift 3 or Xcode 8
- Code has been updated to Swift 3.2; please use
- SwifterSwift
userDefaults
is deprecated, use Apple'sUserDefaults.standard
instead.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
romanNumeral
is now a method.
- Property
- String
- Property
lines
is now a method. - Property
mostCommonCharacter
is now a method. - Property
reversed
is now a method. - Property
unicodeArray
is now a method. - Property
words
is now a method. - Property
wordCount
is now a method.
- Property
- UICollectionView
- Property
numberOfItems
is now a method.
- Property
- UITableView
- Property
numberOfRows
is now a method.
- Property
- UIViewController
- Removed
navigationBar
that 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
isInThisYear
property to check if the date is in the current year. - added
isInThisMonth
property to check if the date is in the current month. - added
isInThisWeek
property 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 structre, 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 + NSAttributedString
operator to return a new appended NSAttributedString. - added
NSAttributedString += String
operator to append a string to a NSAttributedString. - added
NSAttributedString + String
operator to return a new appended NSAttributedString. #218 by @LucianoPAlmeida
- added
- New UIColor extensions
- added
flatUI
struct with all Flat UI colors. #213 by @tache - added
coreImageColor
property to return CoreImage.CIColor. #213 by @tache - added
hsbaComponents
property to get components of hue, saturation, and brightness, and alpha. #213 by @tache - added
uInt
property 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
abs
fromFloatingPointExtensions
andIntExtensions
- moved
isPositive
fromFloatingPointExtensions
andIntExtensions
- moved
isNegative
fromFloatingPointExtensions
andIntExtensions
- moved
string
fromFloatingPointExtensions
andIntExtensions
- moved
asLocaleCurrency
fromFloatingPointExtensions
andIntExtensions
- moved
- New SignedInteger extensions. #224 by @omaralbeik
- moved
isEven
fromIntExtensions
- moved
isOdd
fromIntExtensions
- moved
digits
fromIntExtensions
- moved
digitsCount
fromIntExtensions
- moved
timeString
fromIntExtensions
- moved
gcd(of n)
fromIntExtensions
- moved
lcm(of n)
fromIntExtensions
- moved
- Added
SwifterSwift
module_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
Int
extensions - 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
firstCharacter
has been renamed tofirstCharacterAsString
. #208 by @omaralbeiklastCharacter
has been renamed tolastCharacterAsString
. #208 by @omaralbeikfirstCharacter
has been renamed tofirstCharacterAsString
. #208 by @omaralbeikfloat
has been renamed tofloat(locale: Locale = .current)
. #208 by @omaralbeikdouble
has 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 @omaralbeikint8
is deprecated, useInt8(string)
instead. #208 by @omaralbeikint16
is deprecated, useInt16(string)
instead. #208 by @omaralbeikint32
is deprecated, useInt32(string)
instead. #208 by @omaralbeikint64
is deprecated, useInt64(string)
instead. #208 by @omaralbeikfloat32
is deprecated, useFloat32(string)
instead. #208 by @omaralbeikfloat64
is 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 @omaralbeikredComponent
is deprecated, use the newrgbComponenets.red
instead. #208 by @omaralbeikgreenComponent
is deprecated, use the newrgbComponenets.green
instead. #208 by @omaralbeikblueComponent
is deprecated, use the newrgbComponenets.blue
instead. #208 by @omaralbeik
- New String extensions
- added
cgFloat(locale: Locale = .current)
to get CGFloat value from string. #208 by @omaralbeik - added
words
to return an array of all words in a string. #208 by @omaralbeik - added
wordCount
to get count of words in a string. #208 by @omaralbeik
- added
- New Int extensions
- added
countableRange
to get CountableRange 0..<Int. #208 by @omaralbeik - added
uInt
to 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
hasValidEmail
to check if textFields text is a valid email format. #208 by @omaralbeik - added
textType
to set textField for common text types like email addresses & passwords. #208 by @omaralbeik
- added
- New UIColor extensions
- added
rgbComponenets
to 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
DoubleExtensions
andFloatExtensions
into 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
-
Array
extensions now have throwing signatures. #170 by @LucianoPAlmeida -
New Array extensions
- added
groupByKey
to 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
isValidFileUrl
to 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
bytes
to return data as an array of bytes. #171 by @LucianoPAlmeida
- added
-
New UITextField extensions
- Fixes asynchronous
iOS
/tvOS
/watchOS
unit tests causing crashes. #191 by @LucianoPAlmeida
- New Array extensions
- added
removeAll
passing an array of items. - added
swap
andsafeSwap
extensions to swap to elements in an array. - new
firstIndex
andlastIndex
that returns the (first or last) index where the condition is true. - new
indexes
extension that return indexes where the condition is true. - new
all
andnone
that checks if (all or none) of array elements match condition. - new
last
extension to find the last element that matches condition. - new
reject
extension to filter elements that not matches condition. - new
count
extension to count elements that match condition. - new
forEachReversed
extension to iterate over an array in reverse order. - new
accumulate
extension to reduces an array while returning each interim combination. - new
forEach
with condition to a filtered interaction over the array. - new
keep
extension to keep all elements that in order are until the condition is false. - new
take
extension that returns all elements that in order are until the condition is false. - new
skip
extension that returns all elements that in order are after the condition is false. - new
filtered: map
extension 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
isInWeekday
extension to check if the date is within a weekday period
- new
- New Dictionary extensions
- new
removeAll
extension 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
matches
extension 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
midLocation
to find the half-way point along a great circle path between relative to another point. - new
bearing
to 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
instantiateViewController
with 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
safeSwap
method as a fail-safe way to swap to elements in an array
- added
-
New NSView extensions
borderColor
(IBInspectable)borderWidth
(IBInspectable)cornerRadius
(IBInspectable)height
shadowColor
(IBInspectable)shadowOffset
(IBInspectable)shadowOpacity
(IBInspectable)shadowRadius
(IBInspectable)size
width
addSubviews(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_PI
with.pi
-
Fixes wrong implementation of -=
CGPoint
operator -
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
removeDuplicates
renamed 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:
- scrollToBotom(): 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