Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-11-2010, 12:18 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default Nightmare problem. Same code; works on one view, not on the other: in the SAME APP

This is just weird. I have an app that uses an IBAction to login and post to facebook wall. I was having problems where it would crash on me after loggin in on one view, but the other view would log in just fine. I thought maybe I made a typo somewhere so I completely copied and pasted the code from the working view into the one that wasn't working. They are completely identical, except for me changing the import header file names and the implementation names to be for the correct view. It STILL messed up. Exactly the same code in 2 views, one works one doesn't. How can this be?
Code:
#import "FirstViewController.h"
#import <QuartzCore/QuartzCore.h>

@implementation FirstViewController
@synthesize activity;
@synthesize postentry;
@synthesize currentURL;
@synthesize title;
@synthesize session = _session;
@synthesize postGradesButton = _postGradesButton;
@synthesize logoutButton = _logoutButton;
@synthesize loginDialog = _loginDialog;
@synthesize facebookName = _facebookName;
@synthesize posting = _posting;
@synthesize text;


- (void)viewDidLoad {
	[steve loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://resurrectedliving.wordpress.com"]]];
	timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(tick) userInfo:nil repeats:YES];
	
	// Set these values from your application page on http://www.facebook.com/developers
	// Keep in mind that this method is not as secure as using the sessionForApplication:getSessionProxy:delegate method!
	// These values are from a dummy facebook app I made called MyGrades - feel free to play around!
	static NSString* kApiKey = @"REMOVED ON PURPOSE";
	static NSString* kApiSecret = @"REMOVED ON PURPOSE";
	_session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];
	
	// Load a previous session from disk if available.  Note this will call session:didLogin if a valid session exists.
	[_session resume];
	
	[super viewDidLoad];
}
-(void)tick {
	if(!steve.loading)
		[activity stopAnimating];
	else 
		[activity startAnimating];
	
}

- (IBAction)postGradesTapped:(id)sender {
	_posting = YES;
	// If we're not logged in, log in first...
	if (![_session isConnected]) {
		self.loginDialog = nil;
		_loginDialog = [[FBLoginDialog alloc] initWithSession:_session];	
		[_loginDialog show];	
	}
	// If we have a session and a name, post to the wall!
	else if (_facebookName != nil) {
		[self postToWall];
	}
	// Otherwise, we don't have a name yet, just wait for that to come through.
}

- (IBAction)logoutButtonTapped:(id)sender {
	[_session logout];
}


#pragma mark FBSessionDelegate methods

- (void)session:(FBSession*)session didLogin:(FBUID)uid {
	[self getFacebookName];
}

- (void)session:(FBSession*)session willLogout:(FBUID)uid {
	_logoutButton.hidden = YES;
	_facebookName = nil;
}

#pragma mark Get Facebook Name Helper

- (void)getFacebookName {
	NSString* fql = [NSString stringWithFormat:
					 @"select uid,name from user where uid == %lld", _session.uid];
	NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
	[[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
}

#pragma mark FBRequestDelegate methods

- (void)request:(FBRequest*)request didLoad:(id)result {
	if ([request.method isEqualToString:@"facebook.fql.query"]) {
		NSArray* users = result;
		NSDictionary* user = [users objectAtIndex:0];
		NSString* name = [user objectForKey:@"name"];
		self.facebookName = name;		
		_logoutButton.hidden = NO;
		[_logoutButton setTitle:[NSString stringWithFormat:@"Facebook: Logout as %@", name] forState:UIControlStateNormal];
		if (_posting) {
			[self postToWall];
			_posting = NO;
		}
	}
}

#pragma mark Post to Wall Helper

- (void)postToWall {
	
	FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
	dialog.userMessagePrompt = @"Enter your message:";
	dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@\",\"href\":\"%@\",\"caption\":\"Check out this article by Scott Elliott\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.316apps.com/lagrange.jpg\",\"href\":\"http://resurrectedliving.wordpress.com\"}]}",
						 self.title, self.currentURL];
	[dialog show];
	
}

#pragma mark Memory Cleanup

- (void)viewDidUnload {
	self.postGradesButton = nil;
    self.logoutButton = nil;
}

- (void)dealloc {
    [_session release];
	_session = nil;
	[_postGradesButton release];
	_postGradesButton = nil;
    [_logoutButton release];
	_logoutButton = nil;
    [_loginDialog release];
	_loginDialog = nil;
    [_facebookName release];
	_facebookName = nil;
    [super dealloc];
}




@end
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 09-11-2010, 03:33 AM   #2 (permalink)
N3RD
 
Join Date: Oct 2009
Posts: 201
tychop is on a distinguished road
Default

completly off-topic:
Why on earth do you use underscores?
tychop is offline   Reply With Quote
Old 09-11-2010, 10:24 AM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

Th tutorial I used had them. Any ideas why it works in one view and not the other?
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 09-11-2010, 11:31 AM   #4 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by spiderguy84 View Post
Th tutorial I used had them. Any ideas why it works in one view and not the other?
Usually code that seems perfect, but doesn't work, is due to a broken link in IB. Check all your outlet and action connections to the view controller that doesn't work. I bet you have one or more broken outlet links.

Failing that, step through the code in the debugger and check the values of your variables and the way the code branches.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 09-11-2010, 11:42 AM   #5 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Check the docs - do you need to set the delegate to nil before you release the session? Also, what's the message when you crash? It may hold a clue.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 09-11-2010, 11:50 AM   #6 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

I've checked everything in IB and it is fine, nothing is broken. Also, when I click the button that IB is linked to, it starts off fine, pulls up the FBConnect window, lets me login, then says redirecting like it does right before pulling up the publish to wall window, then it crashes. Here is the debug console after I run it.

Code:
2010-09-11 11:47:28.571 LaGrangeCoC[25381:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: session_key)'
*** Call stack at first throw:
(
	0   CoreFoundation                      0x026f7919 __exceptionPreprocess + 185
	1   libobjc.A.dylib                     0x028455de objc_exception_throw + 47
	2   CoreFoundation                      0x026b0078 +[NSException raise:format:arguments:] + 136
	3   CoreFoundation                      0x026affea +[NSException raise:format:] + 58
	4   CoreFoundation                      0x026f6185 -[__NSCFDictionary setObject:forKey:] + 293
	5   LaGrangeCoC                         0x0000b24b -[FBRequest call:params:dataParam:] + 730
	6   LaGrangeCoC                         0x0000af6b -[FBRequest call:params:] + 58
	7   LaGrangeCoC                         0x00002dda -[FirstViewController getFacebookName] + 236
	8   LaGrangeCoC                         0x00002c83 -[FirstViewController session:didLogin:] + 48
	9   LaGrangeCoC                         0x00008727 -[FBSession resume] + 707
	10  LaGrangeCoC                         0x00011b1c -[FBLoginDialog request:didLoad:] + 478
	11  LaGrangeCoC                         0x0000a6d8 -[FBRequest handleResponseData:] + 228
	12  LaGrangeCoC                         0x0000addd -[FBRequest connectionDidFinishLoading:] + 60
	13  Foundation                          0x00084666 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
	14  Foundation                          0x000845bf _NSURLConnectionDidFinishLoading + 133
	15  CFNetwork                           0x02c899f1 _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 285
	16  CFNetwork                           0x02d52c72 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 402
	17  CFNetwork                           0x02d530ea _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 1546
	18  CFNetwork                           0x02c7edfe _ZN19URLConnectionClient13processEventsEv + 100
	19  CFNetwork                           0x02c7ec95 _ZN17MultiplexerSource7performEv + 247
	20  CoreFoundation                      0x026d8d7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
	21  CoreFoundation                      0x026372cb __CFRunLoopDoSources0 + 571
	22  CoreFoundation                      0x026367c6 __CFRunLoopRun + 470
	23  CoreFoundation                      0x02636280 CFRunLoopRunSpecific + 208
	24  CoreFoundation                      0x026361a1 CFRunLoopRunInMode + 97
	25  GraphicsServices                    0x02f5c2c8 GSEventRunModal + 217
	26  GraphicsServices                    0x02f5c38d GSEventRun + 115
	27  UIKit                               0x002f0b58 UIApplicationMain + 1160
	28  LaGrangeCoC                         0x00002444 main + 102
	29  LaGrangeCoC                         0x000023d5 start + 53
)
terminate called after throwing an instance of 'NSException'
__________________
My latest app...i Miss Mommy

Last edited by spiderguy84; 09-11-2010 at 11:52 AM. Reason: Adding more info
spiderguy84 is offline   Reply With Quote
Old 09-11-2010, 11:59 AM   #7 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by spiderguy84 View Post
I've checked everything in IB and it is fine, nothing is broken. Also, when I click the button that IB is linked to, it starts off fine, pulls up the FBConnect window, lets me login, then says redirecting like it does right before pulling up the publish to wall window, then it crashes. Here is the debug console after I run it.

Code:
2010-09-11 11:47:28.571 LaGrangeCoC[25381:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: session_key)'
*** Call stack at first throw:
(
	0   CoreFoundation                      0x026f7919 __exceptionPreprocess + 185
	1   libobjc.A.dylib                     0x028455de objc_exception_throw + 47
	2   CoreFoundation                      0x026b0078 +[NSException raise:format:arguments:] + 136
	3   CoreFoundation                      0x026affea +[NSException raise:format:] + 58
	4   CoreFoundation                      0x026f6185 -[__NSCFDictionary setObject:forKey:] + 293
	5   LaGrangeCoC                         0x0000b24b -[FBRequest call:params:dataParam:] + 730
	6   LaGrangeCoC                         0x0000af6b -[FBRequest call:params:] + 58
	7   LaGrangeCoC                         0x00002dda -[FirstViewController getFacebookName] + 236
	8   LaGrangeCoC                         0x00002c83 -[FirstViewController session:didLogin:] + 48
	9   LaGrangeCoC                         0x00008727 -[FBSession resume] + 707
	10  LaGrangeCoC                         0x00011b1c -[FBLoginDialog request:didLoad:] + 478
	11  LaGrangeCoC                         0x0000a6d8 -[FBRequest handleResponseData:] + 228
	12  LaGrangeCoC                         0x0000addd -[FBRequest connectionDidFinishLoading:] + 60
	13  Foundation                          0x00084666 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
	14  Foundation                          0x000845bf _NSURLConnectionDidFinishLoading + 133
	15  CFNetwork                           0x02c899f1 _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 285
	16  CFNetwork                           0x02d52c72 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 402
	17  CFNetwork                           0x02d530ea _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 1546
	18  CFNetwork                           0x02c7edfe _ZN19URLConnectionClient13processEventsEv + 100
	19  CFNetwork                           0x02c7ec95 _ZN17MultiplexerSource7performEv + 247
	20  CoreFoundation                      0x026d8d7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
	21  CoreFoundation                      0x026372cb __CFRunLoopDoSources0 + 571
	22  CoreFoundation                      0x026367c6 __CFRunLoopRun + 470
	23  CoreFoundation                      0x02636280 CFRunLoopRunSpecific + 208
	24  CoreFoundation                      0x026361a1 CFRunLoopRunInMode + 97
	25  GraphicsServices                    0x02f5c2c8 GSEventRunModal + 217
	26  GraphicsServices                    0x02f5c38d GSEventRun + 115
	27  UIKit                               0x002f0b58 UIApplicationMain + 1160
	28  LaGrangeCoC                         0x00002444 main + 102
	29  LaGrangeCoC                         0x000023d5 start + 53
)
terminate called after throwing an instance of 'NSException'
The error message at the top is quite specific:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: session_key)'

You're passing a nil value for "session_key" in a dictionary setObject call. Now run the app in the debugger and find the offending line.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 09-11-2010, 12:04 PM   #8 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

Here is the full code for the IBAction I am using to connect.
Code:
- (IBAction)postGradesTapped:(id)sender {
	_posting = YES;
	// If we're not logged in, log in first...
	if (![_session isConnected]) {
		self.loginDialog = nil;
		_loginDialog = [[FBLoginDialog alloc] initWithSession:_session];	
		[_loginDialog show];	
	}
	// If we have a session and a name, post to the wall!
	else if (_facebookName != nil) {
		[self postToWall];
	}
	// Otherwise, we don't have a name yet, just wait for that to come through.
}
The problem line has to be
Code:
_loginDialog = [[FBLoginDialog alloc] initWithSession:_session];
because if I change it to
Code:
_loginDialog = [[FBLoginDialog alloc] init];
it won't crash, the issue is it won't bring up the publish to wall either.
__________________
My latest app...i Miss Mommy

Last edited by spiderguy84; 09-11-2010 at 12:10 PM.
spiderguy84 is offline   Reply With Quote
Old 09-11-2010, 12:42 PM   #9 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by spiderguy84 View Post
Here is the full code for the IBAction I am using to connect.
Code:
- (IBAction)postGradesTapped:(id)sender {
	_posting = YES;
	// If we're not logged in, log in first...
	if (![_session isConnected]) {
		self.loginDialog = nil;
		_loginDialog = [[FBLoginDialog alloc] initWithSession:_session];	
		[_loginDialog show];	
	}
	// If we have a session and a name, post to the wall!
	else if (_facebookName != nil) {
		[self postToWall];
	}
	// Otherwise, we don't have a name yet, just wait for that to come through.
}
The problem line has to be
Code:
_loginDialog = [[FBLoginDialog alloc] initWithSession:_session];
because if I change it to
Code:
_loginDialog = [[FBLoginDialog alloc] init];
it won't crash, the issue is it won't bring up the publish to wall either.
Ok, so your _session instance variable must be nil. Trace the code in the debugger and figure out why _session is nil.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 09-11-2010, 12:47 PM   #10 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

I haven't had a lot of experience with debugging. Could you let me know how to trace the code in the debugger to figure out why, or point me to something that will explain how to do this?
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 09-11-2010, 02:54 PM   #11 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default Using the debugger.

Quote:
Originally Posted by spiderguy84 View Post
I haven't had a lot of experience with debugging. Could you let me know how to trace the code in the debugger to figure out why, or point me to something that will explain how to do this?
There are quite few books that explain debugging. I recommend XCode 3 unleashed. It starts out simple and gets into more in-depth debugging tricks.

It's a deep subject, but here are few points to get you started.

Make sure you are set to build a debug version of the project (in the pop-up at the top left of the project window.)

In editing preferences, make sure you have "Show Gutter" and "Show Line numbers" selected.

Select the file who's code you want to debug. Click on the line number where you want the app to break. It should put a blue pointer over the line number. That adds a breakpoint at that line number.

Run your program. When it gets to a line number where you've added a breakpoint, it will stop and display a message "Stopped at breakpoint ..." At this point you should select "Debugger" from the run menu. That will show the current source file, with an arrow pointing to the line of code that is about to be executed. There will be a section with headers "variable", "Value" and "summary" The variable column will have entires for "Arguments", "Locals", "Globals," "Registers," etc. You'll mostly be interested in "Arguments" and "Locals". Locals shows the local variables defined at the current scope (the current method, and the current set of braces inside that method). "Arguments" lists arguments passed in to a method, as well as having a disclosure triangle for "self", which lets you see the current object's instance variables. When a variable contains a structure, or an object with properties, that variable will also have a disclosure triangle that lets you view the contents.

At the top of the debugger window are buttons to step into the next call, step out of the current method/function and return to the caller, continue running, etc. There is also a "show" item in the run menu that will let you view a list of breakpoints, and disable/add/delete breakpoints, as well as add debugger commands or log statements to your breakpoints.

There's much more to it than that, but that much is very powerful, and will let you examine variables and trace through your code.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 09-11-2010, 04:37 PM   #12 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
There are quite few books that explain debugging. I recommend XCode 3 unleashed. It starts out simple and gets into more in-depth debugging tricks.

It's a deep subject, but here are few points to get you started.

Make sure you are set to build a debug version of the project (in the pop-up at the top left of the project window.)

In editing preferences, make sure you have "Show Gutter" and "Show Line numbers" selected.

Select the file who's code you want to debug. Click on the line number where you want the app to break. It should put a blue pointer over the line number. That adds a breakpoint at that line number.

Run your program. When it gets to a line number where you've added a breakpoint, it will stop and display a message "Stopped at breakpoint ..." At this point you should select "Debugger" from the run menu. That will show the current source file, with an arrow pointing to the line of code that is about to be executed. There will be a section with headers "variable", "Value" and "summary" The variable column will have entires for "Arguments", "Locals", "Globals," "Registers," etc. You'll mostly be interested in "Arguments" and "Locals". Locals shows the local variables defined at the current scope (the current method, and the current set of braces inside that method). "Arguments" lists arguments passed in to a method, as well as having a disclosure triangle for "self", which lets you see the current object's instance variables. When a variable contains a structure, or an object with properties, that variable will also have a disclosure triangle that lets you view the contents.

At the top of the debugger window are buttons to step into the next call, step out of the current method/function and return to the caller, continue running, etc. There is also a "show" item in the run menu that will let you view a list of breakpoints, and disable/add/delete breakpoints, as well as add debugger commands or log statements to your breakpoints.

There's much more to it than that, but that much is very powerful, and will let you examine variables and trace through your code.
I still can't trace back why the _session is returning nil.
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 09-11-2010, 08:33 PM   #13 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

Tried building from scratch and still crashes because of session nil
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 09-11-2010, 08:40 PM   #14 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by spiderguy84 View Post
Tried building from scratch and still crashes because of session nil
Ok, where do you set the value of _session to something other than nil? Set a breakpoint there, and set a breakpoint in the code that uses session. Make sure _session gets set correctly, and then step through the code and see where it is getting set to nil.

On the simulator you can right click on a variable in the debugger and set a "watchpoint," which causes the debugger to watch a variable and detect when it changes. You might try that.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 09-11-2010, 09:16 PM   #15 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

In the viewDidLoad I set this:
Code:
_session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];
In the ViewController.h I import the FBConnect.h that I downloaded from the FBConnect Source Code. Everything with _session comes from the FBSession files. I don't believe an error would be there, because the other ViewController that does work is set up the exact same way. As I've said before, it works in one, and not the other. The only other place I found where _session is set to anything is the dealloc where I have
Code:
[_session release];
_session=nil;
Also the _session resume code is working because if I restart the app and click the IBAction button it still has me logged in and pulls the Publish Story to Wall window up just fine. My head hurts from all this as I've been on it for 48 hours now.
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 09-11-2010, 10:12 PM   #16 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by spiderguy84 View Post
In the viewDidLoad I set this:
Code:
_session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];
In the ViewController.h I import the FBConnect.h that I downloaded from the FBConnect Source Code. Everything with _session comes from the FBSession files. I don't believe an error would be there, because the other ViewController that does work is set up the exact same way. As I've said before, it works in one, and not the other.

The only other place I found where _session is set to anything is the dealloc where I have
Code:
[_session release];
_session=nil;
That sounds like your culprit. Is that code called in the dealloc for your view controller? It sounds like you set up the session, and then when you dismiss the first view controller, you're setting the _session variable to nil;

Put a break point on EVERY line that sets session to nil, and see when it's being called. Really, the debugger is your friend. Learn to use it.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 09-11-2010, 10:45 PM   #17 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

Yes that's the dealloc for the view controller
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 09-11-2010, 10:58 PM   #18 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

I got rid of the
Code:
[_session release];
_session = nil;
and it is still messing up.
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 09-12-2010, 12:36 AM   #19 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

Ok, this is turning into a lot of work and getting away from the original problem I had. The original problem was when I clicked the button it would pop up the login dialog, but then close without ever showing the Publish Story to Wall dialog. I was told that the initWithSession:_session would work, but obviously it is not. How else could I change this code below to log in, then automatically show the post to wall window?
Code:
- (IBAction)postGradesTapped:(id)sender {
	_posting = YES;
	// If we're not logged in, log in first...
	if (![_session isConnected]) {
		self.loginDialog = nil;
		_loginDialog = [[FBLoginDialog alloc] init];	
		[_loginDialog show];
	}
	// If we have a session and a name, post to the wall!
	else if (_facebookName != nil) {
		[self postToWall];
	}
	// Otherwise, we don't have a name yet, just wait for that to come through.
}
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 344
13 members and 331 guests
bignoggins, carlandrews, cgokey, flamingliquid, givensur, hzwegjxg, ilmman, jenniead38, linkmx, mraalex, PixelInteractive, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:55 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0