1

I followed the instructions on http://www.appcoda.com/ios-programming-facebook-login-sdk/

It works, but magically

I don't understand this

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [FBLoginView class];
    [FBProfilePictureView class];

    return YES;
}

What does sending the class message to these classes do? I don't find it in the facebook ios documentation

Cœur
  • 37,241
  • 25
  • 195
  • 267
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
  • did you try removing them? they shouldn't do anything, calling `class` on an object only returns the object's class but it shouldn't have any side effects. – nburk Jan 06 '15 at 08:25
  • 1
    It's probably used to "wake up" the classes, causing them to run their `initialize` class methods. – Droppy Jan 06 '15 at 08:27
  • so it does manual lazy instantiation? – Nick Ginanto Jan 06 '15 at 08:34
  • Could it be linked to [this question](http://stackoverflow.com/questions/1725881/unknown-class-myclass-in-interface-builder-file-error-at-runtime) ? I'm not sure calling the "class" method is supposed to trigger any initialize method is it ? – rdurand Jan 06 '15 at 08:37
  • It might be related. If you set a UIView's class to FBLoginValue in Interface Builder, but never use the class FBLoginValue in your code, it could generate a linker error at runtime, saying “Unknown class FBLoginValue in Interface Builder file”. – rdurand Jan 06 '15 at 08:41

1 Answers1

0

Calling anything on an NSObject has the side effect to call the lazy initialize method once.

That's how FBLoginView is doing its magic. It would have work with [FBLoginView self]; too.

Cœur
  • 37,241
  • 25
  • 195
  • 267