Framework with generic Swift extensions.
github "trifork/TriforkSwiftExtensions" ~> 1.0.7
- Fork
- Branch from either
development
(new features ๐) ormaster
(hot fixes ๐ฅ) - Develop and write unit tests.
- Commit with great messages.
- Push when you are done.
- Create a pull request.
If you need more guidance, then read this.
Happy contributing! ๐
- Array:
- Remove
Element
instances based onEquatable
comparison. forEach
iteration withElement
and index.
- Remove
- Bundle:
- Compile date of the app.
- Version and build number of the app.
- Bundle name of the app.
- Name of build configuration
- Collection:
- Safe index access on
Collection
objects, returningnil
instead of performing index out of bounds crashes.
- Safe index access on
- CGFloat:
- Very important shortcuts for ฯ (๐ฅง)
- CGRect:
midPoint
to return the middle point of the rect.
- Data:
- Conversion to
String
and hexString
.
- Conversion to
- Date:
- Convert to string according to specified
DateFormatter.Style
. - Convert to and from ISO8601 formatted strings.
isToday
,isYesterday
andisTomorrow
.- Get midnight representation of a date instance.
- Convert to string according to specified
- Double:
- Get as string with a maximum or exact number of significant digits.
- Encodable:
- Construct a dictionary containing all the values from an
Encodable
.
- Construct a dictionary containing all the values from an
- Float:
- Get as string with a maximum or exact number of significant digits.
- Optional:
- Passing an
Optional
receiver into another function and returns the other functions result ornil
. - Passing an
Optional
receiver into another function/closure as an unwrapped parameter. - Optional:
- Check whether an optional string is nil or empty.
- Passing an
- NSMutableAttributedString:
- More simple interface to append strings with font and color to
NSMutableAttributedString
. - Constructor with line spacing.
- More simple interface to append strings with font and color to
- NSObject:
- Gets the name of an object's class as a
String
.
- Gets the name of an object's class as a
- LAContext:
- Gets the available type of biometric id, i.e. TouchID, FaceID or None.
- String:
- Base64 encoding and decoding.
- Conversion to
URL
andData
. - URL encoding.
- Check for regular expression matches.
- Validate as phone number or email.
- UIAlertController:
- "OK" alert.
- Presentation with custom tint color.
- Add actions to alerts.
- UIColor:
- Creating
UIColor
instance directly from Zeplin format:"rgb 255 0 255"
- Creating
- UIApplication:
- Open Apple Maps or Google Maps with an address.
- Open URLs safe by asking if is can open the URL first.
- Recursive search for the top most view controller.
- UIDevice:
- Get device model name.
- UIEdgeInsets:
- Construct insets with same distance at all edges.
- UIView:
- Create circled view.
- Get current first responder.
- Round corners on one edge of a view.
- Perform shake animation.
- UIScrollView:
- Handle to set both
contentInsets
andscrollIndicatorInsets
with one property!
- Handle to set both
- UIStackView:
- Remove all arranged subviews.
- UIViewController:
- Convenience function to present an "Okay-
UIAlertController
"
- Convenience function to present an "Okay-
- URL:
- Adding query parameters to
URL
. - Getting values from query parameters in
URL
.
- Adding query parameters to
Some of the extension functions requires specific conditions (e.g. UIView.circle()
needs a square view) and will write to the console using print
if the requirements aren't met.
If you have some custom logging in your project and want to catch the framework's errors it can be done by setting a custom log handler:
TSELogger.customLogErrorHandler = { (message: String) in
//Handle message
}
Note: If the customLogErrorHandler
property is set, the framework will not invoke print
anymore - if you still want this it is your responsibility to invoke it in your custom closure.