I wrote this code. I followed the sample application code provided with facebook SDK. In FeceAppDelegate.m
#import "FaceAppDelegate.h"
#import "FaceViewController.h"
@implementation FaceAppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
@synthesize navigationController=_navigationController;
@synthesize facebook;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
FaceViewController *FaceViewController = [[FaceViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:FaceViewController];
// Initialize Facebook
facebook = [[Facebook alloc] initWithAppId:@"345678" andDelegate:FaceViewController];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
When I run, I have EXC_BAD_ACCESS , and i have a warning , "Instance method alloc not found ..." I think the problem is in
FaceViewController *FaceViewController = [[FaceViewController alloc] init];
the first comment is the right answer. When you do:
FaceViewController *FaceViewController = [[FaceViewController alloc] init];
You've redefined FaceViewController
to be an instance variable within the current scope so alloc
is being sent to the instance which doesn't have a an alloc
method. Change your instance var name and it will work. The convention is to start with lower case for variable names eg faceViewController
.
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.