1

I created a UIView inside the main view of a view controller using the storyboard editor and changed its class to FBProfilePictureView.

enter image description here

I created an outlet:

@property (weak, nonatomic) IBOutlet FBProfilePictureView *userImage;

However, when I refer to the userImage object in code it reports itself as a UIView.

NSLog(@"userImage class: %@", [userImage class]);

Produces:

2012-08-28 17:52:22.196 FBTestApp[6230:707] userImage class: UIView

What am I missing?

Ben Flynn
  • 18,524
  • 20
  • 97
  • 142

3 Answers3

5

While I didn't see the error mentioned in the FB docs, adding:

[FBProfilePictureView class];

To applicationDidFinishLaunching did the trick. Presumably some runtime magic going on.

Ben Flynn
  • 18,524
  • 20
  • 97
  • 142
  • 1
    Just as an addition it does say in the documentation now about adding this line - https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/personalize/ – StuStirling Jul 23 '13 at 11:56
0

I wouldn't rely on [userImage class] for anything other than calling class methods. If you need to ensure userImage is the correct type, use [userImage isKindOfClass:[FBProfilePictureView class]]. It will let you know if you can treat the object as a FBProfilePictureView.

Jeffery Thomas
  • 42,202
  • 8
  • 92
  • 117
  • The key is that in order for the Storyboard to instantiate it as a FBProfilePictureView, this call is needed. I'm not sure what the mechanics are as I don't have access to the source code. I agree that your code could be added for safety before I interact with the object. – Ben Flynn Aug 29 '12 at 02:37
0

A more elegant way to resolve this might be adding the -ObjC linker flag instead of doing this "runtime magic" stuff. Here you can find instructions on how to add the flag!

See the SDK documentation, which says:

Note: If you've added the -ObjC flag to your linker options, then you don't have to add this code. Adding that flag causes the linker to load all the object files in the Facebook SDK, including the FBLoginView class. If you want to know more about what the -ObjC flag does, you can check out our troubleshooting guide.

It mentioned the FBLoginView, but according to the answer to this question, it also works for FBProfilePictureView: FBProfilePictureView object wont show image

Hope this helps.

Community
  • 1
  • 1
Thomas Mondel
  • 1,944
  • 3
  • 20
  • 25