Following the CardTableView example from https://github.com/CosmicMind/Samples/tree/master/Projects/Programmatic/CardTableView
I wrote a simple app which got broken after moving to XCode 9 and Swift 4 as e.g.
/// Calculating dynamic height.
open var height: CGFloat {
get {
return card.heightPreset.rawValue + spacing
}
set(value) {
super.heightPreset.rawValue = value
}
}
(like in https://github.com/CosmicMind/Samples/blob/master/Projects/Programmatic/CardTableView/CardTableView/CardTableViewCell.swift)
isn't working anymore.
return card.heightPreset.rawValue + spacing
Results in the compiler error message: "_Binary operator '+' cannot be applied to operands of type 'Int' and 'CGFloat_'"
super.heightPreset.rawValue = value
Gives "_Cannot assign to property: 'rawValue' is immutable_".
Furthermore, .x, .y and .width setters of a Card are not provided anymore (as e.g. in _CardTableViewCell.layoutSubviews()_).
The general result in my case is that the cells are created, but no content is visible anymore.
Not sure if this is an issue or help needed only.
As a dumb API user 馃槒 I'd say, the API is broken, as just a dumb user 馃槅, I just need help get going...
It looks like you are trying to set a value that is read-only heightPreset.rawValue. If you would like to do what you are doing, try this:
let h = heightPreset.rawValue
return h + spacing
where appropriate.
Thanks for your extremely quick answer first!
It looks like you are trying to set a value that is read-only heightPreset.rawValue.
Actually the code is yours 馃槃 : https://github.com/CosmicMind/Samples/blob/master/Projects/Programmatic/CardTableView/CardTableView/CardTableViewCell.swift
If you would like to do what you are doing, try this:
let h = heightPreset.rawValue
return h + spacing
Hm, why would I _return_ something in the _setter_? I'm sorry not understanding your hint...
I guess, I need to wait until there's a Samples branch for Swift 4...
Best wishes,
Karsten
Lol, I knew it looked familiar ;) Well, I am updating the sample today and over the weekend. So You should have this available shortly. I am going to close this for now, as all samples will be looked at. Thank you!
:) Thanks. Wish I could support you somehow in this Herculean task.
?
Anyway, have a wonderful hackish weekend!
:)
Anything helps my friend :) Pointing out this issue was a great start. Thank you!
Anything helps my friend :)
You're my hero, love this attitude :)
Any update on this? The CardTableView sample dynamic card hasn't been modified yet and I'm having trouble setting the height of the cell since converting to Swift 4. Thanks
@csimmonsbluebook At the moment I am still going through the samples to ensure that everything is correct for the latest Material, Motion, and Swift 4. Sorry if it is broken at the moment, it will be updated shortly.
@danieldahan Sounds good. Thanks man!
@karstengresch Have you found any way around this yet?
I will update the CardTableView sample today, latest tomorrow.
Alright cool. Sorry to be a pain, I know you have plenty of things to tweak with Swift 4 and iOS 11! Just trying to finish up an app update :)
@csimmonsbluebook no worries :)
@csimmonsbluebook
Have you found any way around this yet?
No, I had to switch my project completely away from Material (for the time being). The CardTableView sample still doesn't compile with Swift 4 on my side. My 'time resources'/'knowledge' ratio is extremely low, so I can't be much of help for @danieldahan.
But I'll definitely come back when it's fixed :)
Sample has been updated :) All the best!