无法识别的选择器通过UIButton发送到实例0x7f9d19e02870

时间:2018-07-20 12:52:55

标签: swift firebase button sigabrt

当我单击按钮creaX时,我的应用程序崩溃了,控制台显示了以下错误,并且在Thread 1: signal SIGABRT中显示了AppDelegate。我尝试检查按钮是否有可能没有的插座,但没关系,我尝试将按钮与ViewController断开连接,然后重新连接,我尝试再次创建按钮的动作(从插座和视图控制器中删除前一个),但错误仍然在这里:

    2018-07-20 14:33:35.291935+0200 Friendx[8583:238797] 5.4.0 - [Firebase/Analytics][I-ACS023007] Firebase Analytics v.50001000 started
2018-07-20 14:33:35.292373+0200 Friendx[8583:238797] 5.4.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2018-07-20 14:33:35.491992+0200 Friendx[8583:238287] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x60c00008d480 UILayoutGuide:0x60c0001bef40'UIViewSafeAreaLayoutGuide'.trailing == UIImageView:0x7f9d19e0ad60.trailing + 92   (active)>",
    "<NSLayoutConstraint:0x60c00008d7a0 UIImageView:0x7f9d19e0ad60.leading == UILayoutGuide:0x60c0001bef40'UIViewSafeAreaLayoutGuide'.leading + 91   (active)>",
    "<NSLayoutConstraint:0x60c00008d7f0 UIImageView:0x7f9d19e0ad60.centerX == UIView:0x7f9d19c0e900.centerX   (active)>",
    "<NSLayoutConstraint:0x60c00008d5c0 'UIViewSafeAreaLayoutGuide-left' H:|-(0)-[UILayoutGuide:0x60c0001bef40'UIViewSafeAreaLayoutGuide'](LTR)   (active, names: '|':UIView:0x7f9d19c0e900 )>",
    "<NSLayoutConstraint:0x60c00008d6b0 'UIViewSafeAreaLayoutGuide-right' H:[UILayoutGuide:0x60c0001bef40'UIViewSafeAreaLayoutGuide']-(0)-|(LTR)   (active, names: '|':UIView:0x7f9d19c0e900 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60c00008d7f0 UIImageView:0x7f9d19e0ad60.centerX == UIView:0x7f9d19c0e900.centerX   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2018-07-20 14:33:35.709930+0200 Friendx[8583:238838] TIC Read Status [1:0x0]: 1:57
2018-07-20 14:33:35.710265+0200 Friendx[8583:238838] TIC Read Status [1:0x0]: 1:57
2018-07-20 14:33:36.665526+0200 Friendx[8583:238799] TIC Read Status [2:0x0]: 1:57
2018-07-20 14:33:36.665640+0200 Friendx[8583:238799] TIC Read Status [2:0x0]: 1:57
L'utente è entrato in Google
L'utente è entrato in Firebase
2018-07-20 14:33:37.075278+0200 Friendx[8583:238799] TIC Read Status [3:0x0]: 1:57
2018-07-20 14:33:37.075677+0200 Friendx[8583:238799] TIC Read Status [3:0x0]: 1:57
2018-07-20 14:33:37.555321+0200 Friendx[8583:238880] TIC Read Status [4:0x0]: 1:57
2018-07-20 14:33:37.555642+0200 Friendx[8583:238880] TIC Read Status [4:0x0]: 1:57
2018-07-20 14:33:38.001073+0200 Friendx[8583:238797] TIC Read Status [5:0x0]: 1:57
2018-07-20 14:33:38.001287+0200 Friendx[8583:238797] TIC Read Status [5:0x0]: 1:57
2018-07-20 14:33:38.087722+0200 Friendx[8583:238287] Failed to set (coloreBordiStackView) user defined inspected property on (UIStackView): [<UIStackView 0x7f9d1c128960> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key coloreBordiStackView.
2018-07-20 14:33:38.087990+0200 Friendx[8583:238287] Failed to set (BorderWidth) user defined inspected property on (UIStackView): [<UIStackView 0x7f9d1c128960> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key BorderWidth.
2018-07-20 14:33:38.112372+0200 Friendx[8583:238287] [MC] Lazy loading NSBundle MobileCoreServices.framework
2018-07-20 14:33:38.113527+0200 Friendx[8583:238287] [MC] Loaded MobileCoreServices.framework
2018-07-20 14:33:41.023334+0200 Friendx[8583:238287] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/ManuelSchiavon/Library/Developer/CoreSimulator/Devices/656ECD9D-5F69-49E0-A195-E91AC8494850/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-07-20 14:33:41.030739+0200 Friendx[8583:238287] [MC] Reading from private effective user settings.
2018-07-20 14:33:50.357960+0200 Friendx[8583:238287] -[Friendx.ViewController Create:]: unrecognized selector sent to instance 0x7f9d19e02870
2018-07-20 14:33:50.383496+0200 Friendx[8583:238287] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Friendx.ViewController Create:]: unrecognized selector sent to instance 0x7f9d19e02870'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000104f2d12b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00000001045c1f41 objc_exception_throw + 48
    2   CoreFoundation                      0x0000000104fae024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   UIKit                               0x0000000105cf1f51 -[UIResponder doesNotRecognizeSelector:] + 295
    4   CoreFoundation                      0x0000000104eaff78 ___forwarding___ + 1432
    5   CoreFoundation                      0x0000000104eaf958 _CF_forwarding_prep_0 + 120
    6   UIKit                               0x0000000105abf972 -[UIApplication sendAction:to:from:forEvent:] + 83
    7   UIKit                               0x0000000105c3ec3c -[UIControl sendAction:to:forEvent:] + 67
    8   UIKit                               0x0000000105c3ef59 -[UIControl _sendActionsForEvents:withEvent:] + 450
    9   UIKit                               0x0000000105c3de86 -[UIControl touchesEnded:withEvent:] + 618
    10  UIKit                               0x0000000105b35807 -[UIWindow _sendTouchesForEvent:] + 2807
    11  UIKit                               0x0000000105b36f2a -[UIWindow sendEvent:] + 4124
    12  UIKit                               0x0000000105ada365 -[UIApplication sendEvent:] + 352
    13  UIKit                               0x0000000106426a1d __dispatchPreprocessedEventFromEventQueue + 2809
    14  UIKit                               0x0000000106429672 __handleEventQueueInternal + 5957
    15  CoreFoundation                      0x0000000104ed0101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    16  CoreFoundation                      0x0000000104f6ff71 __CFRunLoopDoSource0 + 81
    17  CoreFoundation                      0x0000000104eb4a19 __CFRunLoopDoSources0 + 185
    18  CoreFoundation                      0x0000000104eb3fff __CFRunLoopRun + 1279
    19  CoreFoundation                      0x0000000104eb3889 CFRunLoopRunSpecific + 409
    20  GraphicsServices                    0x0000000109c159c6 GSEventRunModal + 62
    21  UIKit                               0x0000000105abe5d6 UIApplicationMain + 159
    22  Friendx                             0x0000000102164cd7 main + 55
    23  libdyld.dylib                       0x00000001088f9d81 start + 1
    24  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

ViewController.swift(UIBUTTON ACTION)

@IBAction func Create(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!)
    {
        let userID: String = user.userID
        let nomegruppo = TF_nomegruppo.text
        let membro1 = TF_membro1.text

        if TF_membro1.text == Auth.auth().currentUser?.email {
            self.TF_membro1?.text = "Immetti un' altra email"
            self.BT_creaX?.isEnabled = false

        } else {
            self.BT_creaX?.isEnabled = true
        }

        if (TF_membro1.text != nil) && TF_nomegruppo.text != "" {
            self.BT_creaX?.isEnabled = true
            Database.database().reference().child("Users").child(userID).child("Groups").child(nomegruppo!).setValue(["membro1": TF_membro1])
        } else {
            self.BT_creaX?.isEnabled = false
        }
    }

AppDelegate:

import UIKit
import Firebase
import GoogleSignIn

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {

    var window: UIWindow?



    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FirebaseApp.configure()

        GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
        GIDSignIn.sharedInstance().delegate = self

        return true
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

    return GIDSignIn.sharedInstance().handle(url,
                                             sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
                                             annotation: options[UIApplicationOpenURLOptionsKey.annotation])

    }
    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return GIDSignIn.sharedInstance().handle(url,
                                                 sourceApplication: sourceApplication,
                                                 annotation: annotation)

    }
    func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
        // ...
        if error != nil {
            // ...
            return
        }
        print("L'utente è entrato in Google")

        guard let authentication = user.authentication else { return }
        let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken,
                                                       accessToken: authentication.accessToken
                                                                  )

        // ...
        Auth.auth().signInAndRetrieveData(with: credential) { (authResult, error) in
            if error != nil {
                // ...
                return
            }
            // User is signed in
            // ...
            let userID: String = user.userID
            let userName: String = user.profile.name
            let userEmail: String = user.profile.email
            let userImage = user.profile.imageURL(withDimension: 400).absoluteString  /// url of image square of 400 * 400



            Database.database().reference().child("Users").child(userID).setValue(["Name": userName,"Email": userEmail,"Image": userImage])//Salva il nomeuserName e l'url dell'immagine profilo in Firebase
            self.window?.rootViewController?.performSegue(withIdentifier: "HomeSegue", sender: self) //Per andare al secondo screen, "HomeSegue è il nome del collegamento tra il UIViewController 1 e 2.

                if error != nil {
                    print(error as Any)
                    return



                }
                                }





        print ("L'utente è entrato in Firebase")


    } 

    func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) {
        // Perform any operations when the user disconnects from app here.
        // ...
    }


    func applicationWillResignActive(_ application: UIApplication) {
        // 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.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // 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.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // 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.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // 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.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

}

出了什么问题?

1 个答案:

答案 0 :(得分:0)

此签名是错误的(似乎您在将操作连接到按钮之后更改了参数)

@IBAction func Create(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!)

应该是

@IBAction func Create(_ sender: UIButton)

您还希望按钮从何处为您提供GIDSignIn的值  && GIDGoogleUser,它只能自我提供 并重新分配您分享给他们的价值