Comments (2)
Hi
This is indeed a very strange warning. Like you, I can't see how UICollectionViewCell
could already conform to Reusable
from inside UIKit
… the warning is probably misleading and coming from another problem with the wrong diagnostics from the compiler, maybe?
Strangely enough, I opened a random project on my Mac which uses Reusable, and added extension UICollectionViewCell: Reusable {}
somewhere in the code and rebuild the project, and:
- I do have a new error after adding this new line, but which is justified, and is on an existing code I had in the project which looks like
class LabelCell: UICollectionViewCell, NibReusable { … }
, telling meRedundant conformance of 'LabelCell' to protocol 'Reusable'
… but this one makes sense (since indeed nowUICollectionViewCell
is alreadyReusable
andNibReusable
is atypealias
forNibLoadable & Reusable
, so the compiler is right here) - But I don't reproduce the warning you have about
UICollectionViewCell
already conforming toReusable
inUIKit
though.
What version of Xcode and Swift are you using? Maybe the difference is somewhere there?
Did you try to add the name of the Reusable
module (and not you module) before Reusable
(because the Reusable
protocol comes from the Reusable
framework/module, not your module)? Like extension UICollectionViewCell: Reusable.Reusable {}
?
Also, side note and personal point of view: I also personally don't recommend making UICollectionViewCell
directly conform to Reusable
, because it has the potential risk of making collection view cells even not from your app conform to it, like cells used by other frameworks in your app, for example etc. So I prefer to mark only your own cell classes as conforming. I know it can be repetitive, but I prefer explicit conformance than global implicit conformance that could potentially "leak" to more parts of your app that you intend to. See also the notes in the README in this paragraph:
In case your custom UIViewController, UITableViewCell, etc… is intended to be subclassed and be the parent class of many classes in your app, it makes more sense to add the protocol conformance (StoryboardBased, Reusable, …) to the child classes (and mark them final) than adding the protocol on the parent, abstract class.
from reusable.
Using Xcode 9.2 and Swift 4.0. I hadn't thought about making all cells Reusable being a bad idea before though, and you raised a good point. I've gone back and removed those extensions, and instead made my base classes all conform to Reusable, since I know all my custom cells will be subclassing the base views anyways, and this fixes the warning. Thanks for the help!
from reusable.
Related Issues (20)
- getting error on using cellType(for indexPath:)
- Support for new API introduced on iOS 13
- MKMapView support
- Feature request - allow to use UITableViewCell with custom style
- Swift Package Manager: reusable deployment target warning HOT 3
- SPM xibs (Bundle.module) HOT 1
- Xcode 12.5 warnings HOT 2
- Swift tools version update too high, lower version build failed
- UITableViewHeaderFooterView - Warning with NibReusable
- Sure, go ahead!
- ## Summary
- Feature request - access to root xib view
- Support for reusable UITableViewHeaderFooterView subclasses?
- Privacy Manifest
- Swift 5 Support? HOT 2
- Undefined symbols when compiling for unit tests HOT 1
- Xcode 11 beta 4 compiler error HOT 1
- loadNibContent always loads nib named after base class HOT 14
- is there a way to override sceneStoryboard for StoryboardSceneBased HOT 2
- Swift Package Manager HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reusable.