-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support UITableViewCell & UICollectionViewCell identifiers #19
Comments
Probably better wait for #24 before starting to work on this issue |
Hey @AliSoftware ! In developing a tool with similar features to SwiftGen I built a library that makes extracting (eventually) everything, including UITableViewCell and UICollectionViewCell identifiers in Storyboards much easier. It may be overkill for your use but the library is StoryboardKit. To see UITableView Identifier extraction check seguecode's usage here: ViewControllerClassInfo+seguecode.swift Line 35-66 |
Hey @yoiang Thanks for the input, will take a look later in the week! |
+1 on this. I suggest adding |
+1 |
Feel free to make a PR to make this be implemented and released faster, as I'm pretty busy those days and won't have much time implementing it that soon. |
No worries :-) |
My comment is not related to extension UITableView {
public func dequeueReusableCell<T:UITableViewCell>(type: T.Type) -> T {
let tableCell : T
let cellIdentifier = String(T)
if let cell = self.dequeueReusableCellWithIdentifier(cellIdentifier) as? T {
tableCell = cell
} else if let _ = NSBundle(forClass: T.classForCoder()).pathForResource(cellIdentifier, ofType:"nib") {
registerNib(UINib(nibName: cellIdentifier, bundle: nil), forCellReuseIdentifier: cellIdentifier)
if let cell = NSBundle(forClass: T.classForCoder()).loadNibNamed(cellIdentifier, owner: nil, options: nil)[0] as? T {
tableCell = cell
} else {
//if anyone had better suggestion for fallback, you're welcome to comment
tableCell = T(style: .Default, reuseIdentifier: cellIdentifier)
}
} else {
tableCell = T(style: .Default, reuseIdentifier: cellIdentifier)
}
return tableCell
}
} In code you use it like this: let cell = tableView.dequeueReusableCell(CommentVideoCell) This actually solves 3 problems:
So you can avoid magic string in both cases. As for |
@aisoftware - yes, I missed it ;-) But looking at it now it's not exactly the same approach, is it? |
Just had a great idea for a template once this is implemented. Since Reusable looks up the cell identifier based on the value of the |
I'm on it! 🏃 |
The new reference PR to implement that is now SwiftGen/SwiftGenKit#16 |
@AliSoftware is that still wip ? |
Hi @netbe The feature is still definitely in our roadmap, and we actually renamed the The previous Pull Requests though won't probably completely fit anymore the new code organization, so we might need to rewrite those, but that should actually be easier now, hopefully. I won't give you a deadline though, as I'm not sure how much free time we'll have between all contributors to work on this, so when this will be done, but any contribution in that direction is welcome |
@AliSoftware thanks for the update |
Generate something like this:
Usage:
The text was updated successfully, but these errors were encountered: