views:

637

answers:

2

I'm trying to create an iPhone app that connects to FB using their API. The documentation says to do as such to

session = [[FBSession sessionForApplication:@"key" secret:@"secret" delegate:self]retain];

... but what is this "session" object. How do I define it? If I just use this code I get errors saying that "session" is undefined.

+1  A: 

You'd need to type the session variable, probably something like:

FBSession* session = [[FBSession sessionForApplication:@"key"
                                                secret:@"secret"
                                              delegate:self]
                       retain];

Note that since you're retaining it you'll need to release it appropriately. There are lots of SO questions about Cocoa memory management. However the Apple docs are the bible.

The Facebook API docs should have information about the methods you can call on FBSession types.

nall
+2  A: 

You need to create an instance of an FBSession object. The code shown in the documentation is how you do this.

What you may have missed is that the declaration of the session instance variable is hidden in the header file and isn't shown to you in the example.

all you need to do is make sure that FBSession *session; is declared somewhere within your class.

Jasarien