2015-10-04 61 views
2

我已经创建了一个使用解析服务器的facebook按钮登录。然而,登录按钮被点击我收到一个错误,如时:解析Facebook登录错误 - Swift 2

2015年10月4日18:20:23.040 MyProject的[352:91466] *终止应用程序由于未捕获的异常 'NSInvalidArgumentException',究其原因: ' - [__ NSCFString containsObject:]:无法识别的选择发送到实例0x15615560' *第一掷调用堆栈: (0x22c9b86b 0x3464edff 0x22ca1035 0x22c9ec8f 0x22bce2b8 0x62e355 0x62e1f9 0x1c14dab 0x1c159c1 0x62d5a7 0x61a435 0x61a7f3 0x61a7b5 0x61968d 0x61956f 0x6d5cab 0x6d4e1f 0x6d4ccf 0x49cd08 0x49cf54 0x26de3cc9 0x26de3c55 0x26dcc95b 0x26de35a1 0x26de320f 0x26ddc2d7 0x26dada3d 0x26dac25f 0x22c5e827 0x22c5e417 0x22c5c77f 0x22baf1e9 0x22baefdd 0x2be53af9 0x26e1417d 0x616a74 0x34d79873) 的libC++ abi.dylib:与类型NSException

enter image description here

我使用的功能是作为波纹管的未捕获的异常终止。我只是使用了在swift中解析网站中记录的相同方法。为什么我会收到错误?

@IBAction func button_clicked(sender: AnyObject) { 

    let permissions = ["public_profile"] 

    PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) { 
     (user: PFUser?, error: NSError?) -> Void in 
     if let user = user { 
      if user.isNew { 
       print("User signed up and logged in through Facebook!") 
      } else { 
       print("User logged in through Facebook!") 
      } 
     } else { 
      print("Uh oh. The user cancelled the Facebook login.") 
     } 
    } 
} 

我创建了一个桥接报头作为

#import <Parse/Parse.h> 

    #import "KeychainWrapper.h" 

    #import <FBSDKCoreKit/FBSDKCoreKit.h> 

,并加入到

<key>CFBundleURLTypes</key> 
<array> 
    <dict> 
     <key>CFBundleURLSchemes</key> 
     <array> 
      <string>xxxxxxx</string> 
     </array> 
    </dict> 
</array> 
<key>FacebookAppID</key> 
<string>xxxxxxxxx</string> 
<key>FacebookDisplayName</key> 
<string>My App</string> 
<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSExceptionDomains</key> 
    <dict> 
     <key>facebook.com</key> 
     <dict> 
      <key>NSIncludesSubdomains</key> 
      <true/> 
      <key>NSExceptionRequiresForwardSecrecy</key> 
      <false/> 
     </dict> 
     <key>fbcdn.net</key> 
     <dict> 
      <key>NSIncludesSubdomains</key> 
      <true/> 
      <key>NSExceptionRequiresForwardSecrecy</key> 
      <false/> 
     </dict> 
     <key>akamaihd.net</key> 
     <dict> 
      <key>NSIncludesSubdomains</key> 
      <true/> 
      <key>NSExceptionRequiresForwardSecrecy</key> 
      <false/> 
     </dict> 
    </dict> 
</dict> 

<key>LSApplicationQueriesSchemes</key> 
<string>fbauth2</string> 

我的appDelegate是:

import UIKit 
import FBSDKCoreKit 
import ParseFacebookUtilsV4 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 

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

     Parse.setApplicationId("xxxxxxxxx", clientKey: "xxxxxxxxxxxx") 
     PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions) 

     UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true) 

     return true 
    } 

    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 application(application: UIApplication, 
     openURL url: NSURL, 
     sourceApplication: String?, 
     annotation: AnyObject) -> Bool { 
      return FBSDKApplicationDelegate.sharedInstance().application(application, 
       openURL: url, 
       sourceApplication: sourceApplication, 
       annotation: annotation) 
    } 
} 
+0

您能否提供一些更多的细节?我们很难说出即将发生的事情。 –

+0

你好阿尔文,什么不能分开什么添加更多? – saner

+0

您可以做的最好的事情是在GitHub解析回购中发布一个问题。他们会给你最好的反馈,它与Parse Framework有关。 –

回答

0

我计算出来,

我之前在info.plist中的Facebook权限代码是字符串,但它需要作为数组。

是:

<key>LSApplicationQueriesSchemes</key> 
    <string> 
    <string>fbauth2</string> 
    </string> 

我更新了它:

<key>LSApplicationQueriesSchemes</key> 
    <array> 
    <string>fbapi</string> 
    <string>fbapi20130214</string> 
    <string>fbapi20130410</string> 
    <string>fbapi20130702</string> 
    <string>fbapi20131010</string> 
    <string>fbapi20131219</string> 
    <string>fbapi20140410</string> 
    <string>fbapi20140116</string> 
    <string>fbapi20150313</string> 
    <string>fbapi20150629</string> 
    <string>fbauth</string> 
    <string>fbauth2</string> 
    <string>fb-messenger-api20140430</string> 
    </array>