### Fire strageに画像をアップロードするメソッドを呼ぶとクラッシュする
firebaseを利用してiOSアプリを開発しています。
呼び出し元
let appBackend = AppBackend.instance @IBAction func registerAction(_ sender: UIButton) { let image = UIImageJPEGRepresentation(self.oSetImage.image!, 0.1) appBackend.registerImage(image!) }
firebaseとのやり取りは、別ファイルにまとめてあります。
final class AppBackend { fileprivate init () { } static let instance = AppBackend() let ref = Database.database().reference().child("内緒") let storageRef = Storage.storage().reference(forURL: "内緒") func registerImage(_ image: Data?) { let string = String(Int(NSDate().timeIntervalSince1970)) let imageKey = "images/(string)内緒" // ここで、止まります! storageRef.child("images/(string)内緒") if let putImage = image { storageRef.putData(purImage, metadata: nil) { metaData, error in if (error != nil) { print("Uh-oh, an error occurred!") return } else { print("エラー") } } } ref.child(PrefManager.userID).setValue([ "uid": PrefManager.userID, "imagekey": imageKey ]) } }
エラーメッセージはこれが出ます。
2018-06-26 10:05:05.629808+0900 seirenji-iOS[5788:2169320] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'
*** First throw call stack:
(0x181432d8c 0x1805ec5ec 0x1813cb750 0x1813040cc 0x181303f48 0x102a41be0 0x102a3ae9c 0x10284b308 0x10282fe50 0x102830eb0 0x18b19e64c 0x18b2bf870 0x18b1a4700 0x18b2da1a8 0x18b77fee8 0x18b77cc60 0x18b2174d8 0x18b217010 0x18b216874 0x18b2151d0 0x18b9f6d1c 0x18b9f92c8 0x18b9f2368 0x1813db404 0x1813dac2c 0x1813d879c 0x1812f8da8 0x1832dd020 0x18b315758 0x1028b90b0 0x180d89fc0)
libc++abi.dylib: terminating with uncaught exception of type NSException
error breakpointを仕込むと、ここで止まります!、で、とまります。
何か不備があるのでしょうか?
よろしくお願いします。。。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/26 06:21
2018/06/26 06:40