Good Extensions is a collection of useful and frequently used Swift extensions for iOS development. These extensions aim to simplify and streamline common tasks, making it easier for developers to write clean and concise code.
Create a Package.swift
file and add the package dependency into the dependencies list.
Or to integrate without package.swift add it through the Xcode add package interface.
import PackageDescription
let package = Package(
name: "SampleProject",
dependencies: [
.Package(url: "https://github.com/GoodRequest/GoodExtensions-iOS" from: "addVersion")
]
)
Then is a useful way to set properties with closures just after initializing.
let myLabel = UILabel().then {
$0.textAlignment = .center
$0.textColor = .black
$0.text = "Hello, World!"
}
Use our extensions with .gr
just like this:
guard myArray.gr.contains(index: 7) else { return }
myarray.gr.hasItems
myArray.gr.removedDuplicates()
You can define Publisher for your button or other user interactive elements
private(set) lazy var buttonPublisher = myButton.gr.publisher(for: .touchUpInside)
then subcribe to it and handle the actions whenever user interacts with the element
buttonPublisher
.sink { [weak self] _ in
// do actions
}
.store(in: &cancellables)
GoodExtensions is released under the MIT license. See LICENSE for details.