Comments (6)
Good point on forEach
, didn't know it was iOS9.3+. I thought it was tied to the Swift stdlib, not to iOS version, are you sure it's not compatible with 8+?
NibOwnerLoadable
is generally more useful than NibLoadable
if you plan to integrate your XIB in another XIB or Storyboard. You'll make your class the File's owner of your MyCustomView.xib
, then bind every needed IBOutlet from that File's Owner to the view(s) you put in your MyCustomView.xib
to provide content.
Then, the most interesting part of doing that (instead of using NibLoadable
and having your class be the root via of the XIB and not the File's Owner) is that if in a Storyboard you add a view and change its class to MyCustomView
, it will be of the right class right away, you'll be able to access the MyCustomView
IBOutlets
from that Storyboard or its IBInspectable
properties, and you won't need to load its content by code either (provided that you implemented init(coder:)
in MyCustomView.swift
to call MyCustomView.loadFromNib(owner: self)
)
See my example code which I recently improved to give an example of its usage. I plan to rewrite the README and rearrange paragraphs and give more examples to make all that more clear anyway.
from reusable.
I've just tried forEach
on iOS 8.1 simulator and it works. How can I use a function that's available to iOS 9.3+, on iOS 8.1? That's interesting.
I now get what NibOwnerLoadable
does, thanks for explanation.
from reusable.
As explained, forEach
is part of Swift's stdlib and as Swift runtime is dynamically linked that's logical and not surprising it's available on all iOS versions. What made you think it was only available on iOS 9?
from reusable.
Well, the doc says Availability: iOS (9.3 and later)
, isn't it confusing? :D
from reusable.
Which docs are you referring to?
If you look at the definition of forEach
itself (like, Cmd-click on it) you'll see there's no particular @availability
attribute there.
If you look at the generated documentation at swiftdoc.org you'll see that this method is present as soon as Swift 2.2
I've seen Xcode's "quick help" tooltip report invalid availability versions in the past (Xcode bug); maybe that was what you were referring to as "the docs says…"?
from reusable.
Yes, quick help misled me... Thanks for explanation!
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
- Extension for UICollectionViewCell / UITableViewCell with contentView HOT 6
- Problem while compiling with Carthage HOT 3
- NibReusable should have bundle as an optional parameter HOT 5
- 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.