0

Heads Up: I'm not too comfortable with Objective C to know exactly what I'm talking about..

Here's my life story: My app basically consists of 3 views: main, facebook, and twitter.. No problems with the twitter, no problems switching back and forth between views until... bum bum bum.. I started using the Facebook API in guidance from this site: http://www.mobisoftinfotech.com/blog/iphone/iphone-fbconnect-facebook-connect-tutorial/

Now I can connect to FB and use their API and post without any problem, but when I switch back from the Facebook View on my app to the main view, it switches and then immediately crashes..

FacebookViewController.m

#import "FacebookViewController.h"
#import "Crush_LoveAppDelegate.h"

#define _APP_KEY @"43e37a535cc09c2013bd76fde78dfcc7"
#define _SECRET_KEY @"cc14801521a0c4d1dc31b7cacb891072"

@implementation FacebookViewController
@synthesize facebookFeed;
@synthesize delegate;
@synthesize loginButton;
@synthesize facebookAlert;
@synthesize usersession;
@synthesize username;
@synthesize post;



- (void)viewDidLoad {

Crush_LoveAppDelegate *appDelegate =
(Crush_LoveAppDelegate *)   [[UIApplication
                              sharedApplication]delegate];
if (appDelegate._session == nil){
    appDelegate._session = [FBSession sessionForApplication:_APP_KEY secret:_SECRET_KEY delegate:self];
}

if(self.loginButton == NULL)
    self.loginButton = [[[FBLoginButton alloc] init] autorelease];
loginButton.frame = CGRectMake(110, 200, 100, 50);
[self.view addSubview:loginButton]; 
[super viewDidLoad];
self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];

}


- (IBAction)done:(id)sender {
[self.delegate facebookViewControllerDidFinish:self];
}

FacebookViewController.h

#import <UIKit/UIKit.h>
#import "FBConnect/FBConnect.h"
#import "FBConnect/FBSession.h"
#import "FBConnect/FBRequest.h"
#import "FBConnect/FBStreamDialog.h"

@protocol FacebookViewControllerDelegate;

@interface FacebookViewController : UIViewController <UIApplicationDelegate, FBSessionDelegate, FBRequestDelegate>{
IBOutlet UIWebView *facebookFeed;
id <FacebookViewControllerDelegate> delegate;
FBLoginButton *loginButton;
UIAlertView *facebookAlert;
FBSession *usersession;
NSString *username;
BOOL post;

}

@property(nonatomic,retain) FBLoginButton *loginButton;
@property(nonatomic,retain) UIAlertView *facebookAlert;
@property(nonatomic,retain)  FBSession *usersession;
@property(nonatomic,retain) NSString *username;
@property(nonatomic,assign) BOOL post;
@property (nonatomic, assign) id <FacebookViewControllerDelegate> delegate;
@property (nonatomic, retain) IBOutlet UIWebView *facebookFeed;
- (IBAction)done:(id)sender;
@end


@protocol FacebookViewControllerDelegate
- (void)facebookViewControllerDidFinish:(FacebookViewController *)controller;

- (BOOL)textFieldShouldReturn:(UITextField *)textField;
-(void)getFacebookName;
-(void)postToWall;

@end

I chopped some of the .m off of the post to save space, but you get the idea.. I've narrowed it down and it seems like the problem is caused during this line in .m

        appDelegate._session = [FBSession sessionForApplication:_APP_KEY secret:_SECRET_KEY delegate:self];

I've been trying to debug it myself for a few hours and I don't know enough on my own to diagnose it myself..

Any thoughts?

2 Answers2

0

Im not sure why your app is crashing, but thought I'd mention that there are a few really good Apple WWDC videos about bug checking and crashing in XCode. In particular, "Debugging with Xcode 4 and LLDB" and "Understanding Crash Reports on iPhone OS", both from the WWDC 2010 videos. I believe you need a developer login to access these videos however but certainly worth a look if you're interested in learning more about debugging.

Simon
  • 8,981
  • 2
  • 26
  • 32
  • Thanks for the help, I appreciate it. Perhaps it might have something to do with the session being created and then not transferred to the following view? I'm kinda talking out of my A:/ drive but who knows.. – Merlingoth Aug 23 '11 at 07:32
0

Okay, for anyone else who had this issue, here's what I did..

FacebookViewController.m File

- (void)dealloc {
[username release];
[usersession release];
[loginButton release];  
[super dealloc];
}

I commented out the [loginButton release]; line and it worked oddly enough.. I don't know if this will give me serious problems down the road, but it works for now..

Community
  • 1
  • 1