FBSDKAppEvents.activateApp()无法识别的选择器发送到实例

时间:2015-04-04 15:46:07

标签: ios facebook swift facebook-ios-sdk

我正在尝试将facebook sdk集成到我的应用中,我已经完成了所有的info.plist并导入了sdk步骤。当我运行我的应用程序时,第一次查看时我收到此错误

    2015-04-04 21:09:43.105 TestFBApp[1468:27977] -[__NSCFNumber length]: unrecognized selector sent to instance 0xb0513d5e52c2fe43
2015-04-04 21:09:43.173 TestFBApp[1468:27977] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xb0513d5e52c2fe43'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000103e55a75 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000105e5ebb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000103e5cd1d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x0000000103db49dc ___forwarding___ + 988
    4   CoreFoundation                      0x0000000103db4578 _CF_forwarding_prep_0 + 120
    5   TestFBApp                           0x00000001036fbe9c +[FBSDKGraphRequestPiggybackManager addPiggybackRequests:] + 108
    6   TestFBApp                           0x000000010371a165 -[FBSDKGraphRequestConnection start] + 231
    7   TestFBApp                           0x00000001036fdb9a +[FBSDKServerConfigurationManager _loadServerConfigurationFromServerForAppID:] + 236
    8   TestFBApp                           0x00000001036fda97 +[FBSDKServerConfigurationManager _loadServerConfigurationForAppID:] + 252
    9   TestFBApp                           0x00000001036fce28 +[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:] + 319
    10  TestFBApp                           0x000000010372d663 -[FBSDKLoginTooltipView presentInView:withArrowPosition:direction:] + 260
    11  TestFBApp                           0x000000010372ecf5 -[FBSDKTooltipView presentFromView:] + 968
    12  TestFBApp                           0x00000001037274a4 -[FBSDKLoginButton _showTooltipIfNeeded] + 225
    13  Foundation                          0x00000001044d02e5 __NSFireDelayedPerform + 387
    14  CoreFoundation                      0x0000000103dbd6c4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    15  CoreFoundation                      0x0000000103dbd285 __CFRunLoopDoTimer + 1045
    16  CoreFoundation                      0x0000000103d8059d __CFRunLoopRun + 1901
    17  CoreFoundation                      0x0000000103d7fbc6 CFRunLoopRunSpecific + 470
    18  GraphicsServices                    0x0000000107874a58 GSEventRunModal + 161
    19  UIKit                               0x0000000104b99580 UIApplicationMain + 1282
    20  TestFBApp                           0x00000001036c6c0e top_level_code + 78
    21  TestFBApp                           0x00000001036c6c4a main + 42
    22  libdyld.dylib                       0x000000010855e145 start + 1
    23  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

这是我的appdelegate.swift

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.                

        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    }

    func application(application: UIApplication, openURL url: NSURL, sourceApplication: NSString?, annotation: AnyObject) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
    }



    func applicationWillResignActive(application: UIApplication) {

    }

    func applicationDidEnterBackground(application: UIApplication) {

    }

    func applicationWillEnterForeground(application: UIApplication) {
        // Called as part of the transition from the background to the inactive 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.

        FBSDKAppEvents.activateApp()
    }

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


}

当我删除 FBSDKAppEvents.activateApp()它工作正常。

1 个答案:

答案 0 :(得分:3)

这发生在我身上一次,确保将facebookAppId设置为字符串而不是info.pList中的数字