Swiftpack.co - agruchala/ReusableViewExtensions as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by agruchala.
agruchala/ReusableViewExtensions 0.1.1
Extensions for UIKit reusable views
⭐️ 1
🕓 1 year ago
.package(url: "https://github.com/agruchala/ReusableViewExtensions.git", from: "0.1.1")

ReusableViewExtensions

Version License Platform Carthage compatible Swift Package Manager compatible Build Status

Do You hate registering UITableViewCell by String identifier? Remembering all of them, some in Storyboards, some hidded somewhere in constants?

NO MORE! Use ReusableViewExtensions!

Installation

CocoaPods

ReusableViewExtensions is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ReusableViewExtensions'

Carthage

ReusableViewExtensions is available through Carthage. To install it, simply add the following line to your Cartfile:

github "agruchala/ReusableViewExtensions"

Swift Package Manager

ReusableViewExtensions is available through Swift Package Manager. To install it, simply add the following git link to your packages:

https://github.com/agruchala/ReusableViewExtensions.git

Requirements

  • Swift 4.x

Usage

If You have installed framework everything should work out of the box for Your UITableViewCells and UICollectionViewCells. To use it when You want to get cell in data source

  • add import ReusableViewExtensions to source file
  • use one of extension method from framework, thats it!

Code snippet

Having cell:

class MyCell: UITableViewCell { }

You don't need to add any comformance to cells, extension works for all UITableViewCell and UICollectionViewCell.

Register it for table view

Use func register(_ cellType: Reusable.Type)

...
tableView.register(MyCell.self)
...

For cells with xib files use func register(nibType: Reusable.Type, bundle: Bundle = .main)

Dequeue when needed without casting, just use type!

Use func dequeue<T: Reusable>(for indexPath: IndexPath) -> T

//File header
import ReusableViewExtensions

//Your data source
...
let cell: MyCell = tableView.dequeue(for: indexPath)
...

Check Example to see how it works with xib and cell added from code :)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

My name is Artur, I'm developer from Poland:)

License

ReusableViewExtensions is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 1
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics