Comments (18)
@pmodernme Have you been able to use custom cells with your section implementation?
from firebaseui-ios.
So I think this is actually a bug in Swift and the __kindof(Class) implementation. I can't seem to ever use the appropriate subclass in Swift, even though it works in Obj-C. I just recommend forcing the cast to make this work:
self.dataSource.populateCellWithBlock { (cell: UITableViewCell, obj: NSObject) -> Void in
// Populate cell as you see fit, like as below
var customCell = cell as! CustomTableViewCell;
let snapshot = obj as! FDataSnapshot; // danger this can be null on deletion!
}
Looks like I might have to update the docs as well as bother Apple about why this behavior fails.
from firebaseui-ios.
Yes, using the prototype cell data source construction method.
On Wednesday, November 11, 2015, Kerman [email protected] wrote:
@pmodernme https://github.com/pmodernme Have you been able to use
custom cells with your section implementation?—
Reply to this email directly or view it on GitHub
#16 (comment)
.
from firebaseui-ios.
@pmodernme @mcdonamp I had tried it before but my custom cell implementation was messed up so it ended up failing - it's all good now though :)
Also quick question, is it possible to execute a certain function to determine the title of that section? An important use case for this would be if you had a boolean, date or number and you don't want the titles to just be raw values which don't make sense (updated_at = 1447059191006). Maybe a method for self.sectionKeyPath with the snapshot being passed and a string to be returned?
from firebaseui-ios.
When multiple objects are edited, I get this error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the table view after the update (3) must be equal to the number of sections contained in the table view before the update (3), plus or minus the number of sections inserted or deleted (1 inserted, 0 deleted).'
Presumably the data source is getting changed in multiple places without proper handling.
@mcdonamp Will @pmodernme's branch be merged into the actual FirebaseUI or will it remain as is?
from firebaseui-ios.
@kermankohli can you please post some code that's causing this so we can repro? We should never have gotten multiple objects at once to update multiple rows, so maybe something isn't being added/removed properly?
We're working on getting 0.3 out (see demm-auth for the latest) by next week, so we'll switch to getting #12 and #13 in after that.
from firebaseui-ios.
Don't think code will be useful here, basically on a presented modal view controller I'm using multi-path writes to update a few objects in my tableview where the sections are based on the "updated_at" child value (which is being written to all the objects).
Also instead of dataSource.array.sectionKeyPath being a string, can it be changed to be a method like:
func returnSectionKeyPath(keypath: String, forSnapshot: FDataSnaphot) -> String {
// code to determine name of section
return nameOfSection
}
Since usually sections can't be read straight from their values (eg bools, dates - stored as epoch, or ids).
from firebaseui-ios.
@kermankohli is this bug happening in the sectioning code or in the current 0.2 version?
from firebaseui-ios.
The code from pull request #13, and on
- (void)sectionAddedAtSectionIndex:(NSUInteger)section {
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:section]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
more specifically
from firebaseui-ios.
@kermankohli Can you please file as an issue referencing #13 so it can be triaged and tracked appropriately?
from firebaseui-ios.
Sorry to revive this, but I'm having the same issue and the docs don't really mention this as an issue. I've tried forcing the cast to make it work, but I'm running into the same wall as this person.
I'm still trying to resolve this, but could this... Swift bug? be mentioned in the docs?
from firebaseui-ios.
Many of the bugs in the sectioning pull request are resolved in the
FirebaseSet pull request.
On Friday, February 5, 2016, Mario Muñiz [email protected] wrote:
Sorry to revive this, but I'm having the same issue and the docs don't
really mention this as an issue. I've tried forcing the cast to make it
work, but I'm running into the same wall as this person.
http://stackoverflow.com/questions/33731631/firebaseui-swift-cast-value-of-uitableviewcell-to-custom-class#I'm still trying to resolve this, but could this... Swift bug? be
mentioned in the docs?—
Reply to this email directly or view it on GitHub
#16 (comment)
.
from firebaseui-ios.
it would be helpfull to share my simple not working code
as document said at http://cocoadocs.org/docsets/FirebaseUI/0.2.5/
i wrote
self.dataSource.populateCellWithBlock { (cell: KoMsgTableViewCell, obj: NSObject) -> Void in
like
self.dataSource.populateCellWithBlock { (cell: YourCustomClass, obj: NSObject)
but not worked it says
expected type is cell:uitableviewcell
then tried that
self.dataSource.populateCellWithBlock { (cell: UITableViewCell, obj: NSObject) -> Void in
let snap = obj as! FDataSnapshot
let MyCell = cell as! KoMsgTableViewCell
MyCell.LblSender.text = snap.childSnapshotForPath("body").value as! String
}
but it give out fatal error at runtime
fatal error: unexpectedly found nil while unwrapping an Optional value
though I inited by class by
class KoMsgTableViewCell: UITableViewCell {
override init (style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
from firebaseui-ios.
Yes. That's exactly the same problem I ran into. Essentially the same code.
from firebaseui-ios.
@kemalony @gulci The unexpectedly found nil likely comes from snap.childSnapshotForPath("body").value as! String
since what you should be using is snap.value["body"] as! String
. The childSnapshotForPath
returns a snapshot (of type FDataSnapshot?
in this case, it's nil), not the value of the object (which you assume would be a String
), which is why the call is failing: you're saying "trust me it'll be a String" but getting an FDataSnapshot
. Check out our docs for more info.
On the other issue of the cell casting not working--again, it's XCode, Swift, and __kindof()
not being supported, there's not much we can do other than change the docs ;)
For future reference, the cell and object are both marked as non null (see https://github.com/firebase/FirebaseUI-iOS/blob/master/FirebaseUI/Core/API/FirebaseTableViewDataSource.h#L403), so those are pretty much guaranteed not to fail the casts.
from firebaseui-ios.
The documentation says we need to use the constructor with "prototypeReuseIdentifier" instead of "cellReuseIdentifier" but I can't see the exact same constructor with the "prototypeReuseIdentifier". The constructors that have "prototypeReuseIdentifier" as parameter do not have "cellClass" parameter that I used with "cellReuseIdentifier". Can you please explain how to use the constructor with the parameter prototypeReuseIdentifier to populate a custom table view cell? If possible, direct me to some tutorial or example code please. Thanks.
Currently the screenshot of my error is:
from firebaseui-ios.
@muratyasarr In general, if you're using a storyboard, you put the custom class in the storyboard (specifically, in the prototype cell) rather than register it on the class--the double registration causes a bunch of sticky issues. If you're using Obj-C, you can easily cast in the block to a UITableViewCell or UICollectionViewCell subclass of your choice, as so:
self.dataSource = [[FirebaseTableViewDataSource alloc] initWithRef:firebaseRef prototypeReuseIdentifier:@"<YOUR-REUSE-IDENTIFIER>" view:self.tableView];
[self.dataSource populateCellWithBlock:^(MyCustomCell *cell, FDataSnapshot *snap) {
// Populate cell as you see fit, like as below
}];
...
If you're using Swift, for the reasons discussed above, __kindof() doesn't seem to work
so you're stuck casting in the cell:
self.dataSource = FirebaseTableViewDataSource(ref: firebaseRef prototypeReuseIdentifier: @"<YOUR-REUSE-IDENTIFIER>" view: self.tableView)
self.dataSource.populateCellWithBlock { (cell: UITableViewCell, obj: NSObject) -> Void in
let newCell = cell as! MyCustomCell
// Populate cell as you see fit
}
...
When in doubt, the code explains this best: https://github.com/firebase/FirebaseUI-iOS/blob/master/FirebaseUI/Core/Implementation/FirebaseTableViewDataSource.m#L286
We will always return an appropriate cell using dequeueReusableCellWithIdentifier: forIndexPath:indexPath
which according to Apple's docs "A __kindofUITableViewCell
object with the associated reuse identifier. This method always returns a valid cell."
from firebaseui-ios.
Also, this thread has drifted quite a bit, so I'll be locking it. If there's a new, different issue, please file a new issue.
from firebaseui-ios.
Related Issues (20)
- Facebook Dependency Update to 15.0.0 HOT 1
- How to use? HOT 2
- Update GoogleSignIn to version 7.0.0 to fix GTMSessionFetcher 3.x issue HOT 1
- default email address not working for signup HOT 2
- `sd_setImage(with:maxImageSize:placeholderImage:options:completion:)` crashing the app when using `.progressiveLoad` HOT 1
- [Breaking] Auth.auth().useUserAccessGroup not functioning in iOS 16 HOT 2
- visionOS platform support
- [Phone Auth] Building with Xcode 14.3.X, displays wrong country code HOT 5
- Please support Facebook SDK 16+ HOT 2
- Update documentation to describe how use it with SPM HOT 3
- The FIRUser displayName appears empty when using 'Sign in with Apple' HOT 1
- Multiple user creation requests on Firebase when user repeatedly taps the Save button HOT 1
- Cannot login using Firebase UI HOT 2
- FUIAnonymousAuth - Missing ProgressView causing simultaneous auth attempts HOT 1
- Login with existing email/password account issue. HOT 1
- Enable email enumeration protection HOT 2
- Privacy manifest required by Apple HOT 1
- SPM - Facebook SDK version range outdated (..<"16.0.0") HOT 2
- Dependency GoogleSignIn need privacyInfo? HOT 1
- Cannot assign value of type 'AppDelegate' to type '(any FUIAuthDelegate)?' HOT 2
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 firebaseui-ios.