简体   繁体   中英

iOS swift facebook login button is not showing up if i don't use classForCoder

I am trying to integrate Facebook single sign on to one of my iOS application. I have followed the instructions from Facebook and when i try to run the application i am getting the following error

Unknown class FBSDKLoginButton in Interface Builder file.

After searching on web, i found that adding the following code will resolve the issue.

FBSDKLoginButton.classForCoder()

My question is, what is the significant of this code? What does this perform behind the scene?

From Apple's Foundation Framework Reference :

classForCoder is a property Overridden by subclasses to substitute a class other than its own during coding. (read-only) Overridden by subclasses to substitute a class other than its own during coding. (read-only)

This method is invoked by NSCoder. NSObject's implementation returns the receiver's class. The private subclasses of a class cluster substitute the name of their public superclass when being archived.

Declaration :

var classForCoder: AnyClass { get }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM