-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ios error when trying to add photo #25
Comments
@iulukaya could you have a look? |
It's related to your storage not enabled. If you just click the storage tab in your Firebase console, it'll set it up for you and upload will work next time you try. |
@iulukaya I can upload a file from the storage tab in the console. However, in the code it bombs out to debugger both when I try to upload a file and when I cancel out of the upload attempt. Here is the code and dump when I try to upload an image: I don't want you or I to go down a rabbit hole here, so if there is anything else I can help you with to clarify, please let me know...thx... scott |
UpdateCode bombs out in This Bombs override func viewWillAppear(animated: Bool) {
self.messages.removeAll()
// Listen for new messages in the Firebase database
_refHandle = self.ref.child("messages").observeEventType(.ChildAdded, withBlock: { (snapshot) -> Void in
self.messages.append(snapshot)
self.clientTable.insertRowsAtIndexPaths([NSIndexPath(forRow: self.messages.count-1, inSection: 0)], withRowAnimation: .Automatic)
})
} Commenting out override func viewWillAppear(animated: Bool) {
// self.messages.removeAll()
// Listen for new messages in the Firebase database
_refHandle = self.ref.child("messages").observeEventType(.ChildAdded, withBlock: { (snapshot) -> Void in
self.messages.append(snapshot)
self.clientTable.insertRowsAtIndexPaths([NSIndexPath(forRow: self.messages.count-1, inSection: 0)], withRowAnimation: .Automatic)
})
} |
I have had the same problem. I moved the viewWillAppear code inside the viewDidLoad. Everything seems to be working fine. I am still a noobie but firebase is real time so I don't see why not just putting the observeEventType code into the viewDidLoad since its going to run still when you add a photo or text. It is duplicating because viewDidAppear is running every time you dismiss the view controller associated with the Camera Picker. Just trying to help out. Hope this helps. |
missing override func viewDidAppear(animated: Bool) {
self.messages.removeAll()
self.clientTable.reloadData()
// Listen for new messages in the Firebase database
_refHandle = self.ref.child("messages").observeEventType(.ChildAdded, withBlock: { (snapshot) -> Void in
self.messages.append(snapshot)
let indexPath = NSIndexPath(forRow: self.messages.count-1, inSection: 0)
self.clientTable.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
self.clientTable.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Bottom, animated: true)
})
} |
@JosephGarcia by moving the code from override func viewWillDisappear(animated: Bool) {
self.ref.removeObserverWithHandle(_refHandle)
} |
@ethanneff did you actually mean self.clientTable.reloadData() should be added to viewWillAppear() as instructed in the tutorial? |
Slightly off topic, but I just noticed the image is saved wrapped in an optional. Looking for that and why "sent by: " is displayed in the chat view... |
@JosephGarcia Thx for the comment. I was looking into what you were saying when @ethanneff helped clarify. @ecaplain Yes is seems to me that @ethanneff meant @ethanneff I tested this really quickly and you are right, the code stopped bombing into debugger. However it seems I am still getting double entries in my list when I add pictures. This could be a remnant of code on my part, so I will try look at further tomorrow... here is my current code snippet where list prints twice: override func viewWillAppear(animated: Bool) {
self.messages.removeAll()
self.clientTable.reloadData()
// Listen for new messages in the Firebase database
_refHandle = self.ref.child("messages").observeEventType(.ChildAdded, withBlock: { (snapshot) -> Void in
self.messages.append(snapshot)
self.clientTable.insertRowsAtIndexPaths([NSIndexPath(forRow: self.messages.count-1, inSection: 0)], withRowAnimation: .Automatic)
})
} |
@bdonkey It's actually tableView() that gets called twice when an image is uploaded, not viewWillAppear, but I haven't figured out why yet... |
i am having same issue here. The original code from Firebase tutorial crashes app when selecting a photo. Reloading table as specified here in this issue thread, just creates a dual "sent by" with username and then photo when clicked. |
Same problem here. Loading the copleted app from firebase codelab, app crashes with "'Invalid update: invalid number of rows in section 0" As OP stated. Adding self.clientTable.reloadData() after self.messages.removeAll() in viewWillAppear() fixes the error, but loads the image twice in the table.
|
Hey everyone, This thread on stackoverflow shows you how to solve this issue. Need to add this code to viewWillDisappear self.ref.child("messages").removeObserverWithHandle(_refHandle) |
Updated the code to fix this problem |
2016-05-20 14:37:10.156 FriendlyChatSwift[32573:72997859] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UITableView.m:1716 2016-05-20 14:37:10.162 FriendlyChatSwift[32573:72997859] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (7), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).' *** First throw call stack: ( 0 CoreFoundation 0x0000000108852d85 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010a9bddeb objc_exception_throw + 48 2 CoreFoundation 0x0000000108852bea +[NSException raise:format:arguments:] + 106 3 Foundation 0x0000000108ca3d5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198 4 UIKit 0x00000001095394ca -[UITableView _endCellAnimationsWithContext:] + 15146 5 UIKit 0x000000010954fcf0 -[UITableView _updateRowsAtIndexPaths:updateAction:withRowAnimation:] + 303 6 FriendlyChatSwift 0x0000000105a13f16 _TFFC17FriendlyChatSwift16FCViewController14viewWillAppearFSbT_U_FCSo15FIRDataSnapshotT_ + 774 7 FriendlyChatSwift 0x0000000105adf419 __63-[FIRDatabaseQuery observeEventType:withBlock:withCancelBlock:]_block_invoke + 37 8 FriendlyChatSwift 0x0000000105b064bc __43-[FChildEventRegistration fireEvent:queue:]_block_invoke64 + 88 9 libdispatch.dylib 0x000000010b467d9d _dispatch_call_block_and_release + 12 10 libdispatch.dylib 0x000000010b4883eb _dispatch_client_callout + 8 11 libdispatch.dylib 0x000000010b4701ef _dispatch_main_queue_callback_4CF + 1738 12 CoreFoundation 0x00000001087ac0f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 13 CoreFoundation 0x000000010876db99 __CFRunLoopRun + 2073 14 CoreFoundation 0x000000010876d0f8 CFRunLoopRunSpecific + 488 15 GraphicsServices 0x000000010c8bcad2 GSEventRunModal + 161 16 UIKit 0x0000000109409f09 UIApplicationMain + 171 17 FriendlyChatSwift 0x0000000105a1974d main + 125 18 libdyld.dylib 0x000000010b4bc92d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException
The text was updated successfully, but these errors were encountered: