IOSでFirebaseを使って、簡易的なチャットアプリを作りました。しかし、起動時にエラーがでてしまいます。
ViewController.siwft
swift
1import UIKit 2import Firebase 3 4class ViewController: UIViewController,UITextFieldDelegate { 5 6 @IBOutlet weak var textView: UITextView! 7 8 9 @IBOutlet weak var messageTextField: UITextField! 10 11 var dataBaseRef:FIRDatabaseReference! 12 @IBOutlet weak var nameTextField: UITextField! 13 14 override func viewDidLoad() { 15 super.viewDidLoad() 16 17 messageTextField.delegate = self 18 nameTextField.delegate = self 19 20 dataBaseRef = FIRDatabase.database().reference() 21 // Do any additional setup after loading the view, typically from a nib. 22 23 dataBaseRef.observe(.childAdded, with: { FIRDataSnapshot in 24 if let name = FIRDataSnapshot.value(forKey: "name") as? String, 25 let message = FIRDataSnapshot.value(forKey: "message") as? String { 26 self.textView.text = "\(self.textView.text)\n\(name) : \(message)" 27 } 28 }) 29 } 30 31 func textFieldShouldReturn(_ textField: UITextField) -> Bool { 32 33 let messageData = ["name": nameTextField.text!, "message": messageTextField.text!] 34 dataBaseRef.childByAutoId().setValue(messageData) 35 textField.resignFirstResponder() 36 messageTextField.text = "" 37 38 return true 39 } 40 41 override func didReceiveMemoryWarning() { 42 super.didReceiveMemoryWarning() 43 // Dispose of any resources that can be recreated. 44 } 45}
AppDelegate.swift
swift
1import UIKit 2import Firebase 3 4@UIApplicationMain 5class AppDelegate: UIResponder, UIApplicationDelegate { //ここでThread 1: signal SIGABRTが出ます。 6 7 var window: UIWindow? 8 9 10 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 11 // Override point for customization after application launch. 12 FIRApp.configure() 13 return true 14 } 15 16 func applicationWillResignActive(_ application: UIApplication) { 17 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 18 // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 19 } 20 21 func applicationDidEnterBackground(_ application: UIApplication) { 22 // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 23 // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 24 } 25 26 func applicationWillEnterForeground(_ application: UIApplication) { 27 // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 28 } 29 30 func applicationDidBecomeActive(_ application: UIApplication) { 31 // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 32 } 33 34 func applicationWillTerminate(_ application: UIApplication) { 35 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 36 } 37}
デバッグエリアの最後には以下のようなメッセージがありました。
libc++abi.dylib: terminating with uncaught exception of type NSException
おそらくこのエラーが原因だと思うのですが、直し方がわかりません。
回答宜しくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/26 03:23
2016/11/26 14:55