Pang Ho Ming
Pang Ho Ming

Reputation: 1319

Facebook iOS SDK cant work with iOS5 and storyboard

i followed the instruction in this link https://developers.facebook.com/docs/mobile/ios/build/

and i have created an iOS Facebook SDK static library ,,,the compiler keeps on saying there are problem with the iniWithAppId and Delegate method

error Log

2012-04-12 14:11:10.569 comman[2609:f803] -[Facebook initWithAppId:withDelegate:]: unrecognized selector sent to instance 0x68970e0

2012-04-12 14:11:10.572 comman[2609:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Facebook initWithAppId:withDelegate:]: unrecognized selector sent to instance 0x68970e0'

* First throw call stack: (0x13d7052 0x1568d0a 0x13d8ced 0x133df00 0x133dce2 0x209a 0x2c9d6 0x2d8a6 0x3c743 0x3d1f8 0x30aa9 0x12c1fa9 0x13ab1c5 0x1310022 0x130e90a 0x130ddb4 0x130dccb 0x2d2a7 0x2ea9b 0x1ff2 0x1f65)

terminate called throwing an exceptionsharedlibrary apply-load-rules all

Current language: auto; currently objective-c

(gdb)

#import <UIKit/UIKit.h>
#import "FBConnect.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate, FBSessionDelegate>{
           Facebook *facebook;
}

@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, retain) Facebook *facebook;

@end

above is my app delegate header and here is my app delegate implementation file

#import "AppDelegate.h"

@implementation AppDelegate


@synthesize window = _window;
@synthesize facebook;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    facebook = [[Facebook alloc] initWithAppId:@"215686948531995" withDelegate:self];

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]){
        facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}

   // NSArray *permissions = [[NSArray arrayWithObjects:@"read_stream", @"publish_stream", @"offline_access", nil]retain];
    if(![facebook isSessionValid]){
        [facebook authorize:nil];
    }
    // Override point for customization after application launch.
    return YES;
}

is the method demonstrated on the facebook developers only suit for xcode 4 or ios 4.3? can anyone give me some advices ,,how to write classes for ios5 storyboard :3

Upvotes: 0

Views: 2235

Answers (2)

Rh Jov
Rh Jov

Reputation: 115

static NSString* kAppId = @"yourAppId";

_facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:self];

Upvotes: 1

AC2MO
AC2MO

Reputation: 1637

I just implemented this yesterday myself and it worked perfectly (static Facebook library, using Storyboards). The only difference I can see (which WILL cause a problem), is that you're calling:

facebook = [[Facebook alloc] initWithAppId:@"215686948531995" withDelegate:self];

and I'm calling:

facebook = [[Facebook alloc] initWithAppId:@"215686948531995" andDelegate:self];

I believe the mistake of using withDelegate instead of andDelegate will give you this error.

Upvotes: 0

Related Questions