Is there a reason why viewDidLoad would not be called?

  • Hi,
    I'm writing an app that should be calling viewDidLoad, but it doesn't call
    it.  This app has to have a shared variable in the appDelegate and the
    variable is also used by the viewController.  I have a working copy from before I tried to put the variable in the appDelegate (importPic2WedMay2.zip) (but that also winds up at a white screen for some reason after login...from what I've read, that is because I need my Facebook variable in the app delegate), and then I have a copy after I moved the variable to the appDelegate
    (importPicWedMay2.zip) that doesn't get to viewDidLoad and the login. 
    Is there anyone out there that might understand this?  I'm not sure what could cause this.  I also have an ios4 version that works, but I need it to be in ios5, so I'm trying to convert it.  I can send a copy of what I have if anyone is interested in seeing it. 

    Thanks,
    M

    (note that there is a supporting file list that includes infoPlist, and the static arc corrected Facebook-ios-sdk obtained by running their script

    This is a few snippets from importPicWedMay2.zip:

    ********************this is my app delegate.h
    #import <UIKit/UIKit.h>
    #import "FBConnect.h"

    @interfaceImportPicAppDelegate : UIResponder<UIApplicationDelegate, UIAlertViewDelegate> {
        Facebook *facebook; 
    }

    @property(strong, nonatomic) UIWindow*window;
    @property(nonatomic, retain) Facebook* facebook;
    @property (nonatomic, retain) NSMutableDictionary *userPermissions;
    //@property (nonatomic, strong) Settings *settingsvc;

    @end

    *******************this is my app delegate.m

    #import "ImportPicAppDelegate.h"
    #import "RootViewController.h"
    #import "ImportPicViewController.h"

    @interfaceImportPicAppDelegate()

    @end

    staticNSString* kAppId = @"210849718975311";

    @implementation ImportPicAppDelegate

    @synthesize window = _window;
    @synthesize facebook = _facebook;
    @synthesize userPermissions = _userPermissions;

    - (BOOL) application:(UIApplication *)application handleOpenURL:(NSURL *)url
    {
        return [facebook handleOpenURL:url];
    }

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        RootViewController *rootViewController = [[RootViewController alloc] init];    // Initialize Facebook
        facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:rootViewController];
        
        // Check and retrieve authorization information
        NSUserDefaults*defaults = [NSUserDefaultsstandardUserDefaults];
        if([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
            facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
            facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
        }
        
        // Initialize API data (for views, etc.)
        //apiData = [[DataSet alloc] init];
        
        // Initialize user permissions
        self.userPermissions= [[NSMutableDictionaryalloc] initWithCapacity:1];
        
        // Override point for customization after application launch.
        // Add the navigation controller's view to the window and display.
        //self.window.rootViewController = self.navigationController;
        //[self.window makeKeyAndVisible];
        
        // Check App ID:
        // This is really a warning for the developer, this should not
        // happen in a completed app
        if (!kAppId) {
            NSLog(@"Missing app ID kAppId");
            /*UIAlertView *alertView = [[UIAlertView alloc]
                                      initWithTitle:@"Setup Error"
                                      message:@"Missing app ID. You cannot run the app until you provide this in the code."
                                      delegate:self
                                      cancelButtonTitle:@"OK"
                                      otherButtonTitles:nil,
                                      nil];*/
            //[alertView show];
            //[alertView release];
        } else{ //??check plist
            // Now check that the URL scheme fb[app_id]://authorize is in the .plist and can
            // be opened, doing a simple check without local app id factored in here
            NSString *url = [NSString stringWithFormat:@"fb%@://authorize",kAppId];
            BOOLbSchemeInPlist = NO; // find out if the sceme is in the plist file.
            NSArray* aBundleURLTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];
            if ([aBundleURLTypes isKindOfClass:[NSArray class]] &&
                ([aBundleURLTypes count] > 0)) {
                NSDictionary* aBundleURLTypes0 = [aBundleURLTypes objectAtIndex:0];
                if ([aBundleURLTypes0 isKindOfClass:[NSDictionary class]]) {
                    NSArray* aBundleURLSchemes = [aBundleURLTypes0 objectForKey:@"CFBundleURLSchemes"];
                    if ([aBundleURLSchemes isKindOfClass:[NSArray class]] &&
                        ([aBundleURLSchemes count] > 0)) {
                        NSString *scheme = [aBundleURLSchemes objectAtIndex:0];
                        if ([scheme isKindOfClass:[NSString class]] &&
                            [url hasPrefix:scheme]) {
                            bSchemeInPlist = YES;
                        }
                    }
                }
            }
            // Check if the authorization callback will work
            BOOLbCanOpenUrl = [[UIApplicationsharedApplication] canOpenURL:[NSURLURLWithString: url]];
            if (!bSchemeInPlist || !bCanOpenUrl) {
                NSLog(@"Invalid or missing URL scheme");
                /*UIAlertView *alertView = [[UIAlertView alloc]
                                          initWithTitle:@"Setup Error"
                                          message:@"Invalid or missing URL scheme. You cannot run the app until you set up a valid URL scheme in your .plist."
                                          delegate:self
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil,
                                          nil];*/
                //[alertView show];
                //[alertView release];
            }
        }
        
        returnYES;
    }

    // For iOS 4.2+ support
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
      sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
        //self.kAppID = @"224207854355440";
        //return YES;
        return [facebook handleOpenURL:url]; 
    }

    ***********************************************this is from my RootVC:
    #import "RootViewController.h"
    #import "ImportPicAppDelegate.h"
    #import "FBConnect.h"
    #import "ImportPicViewController.h"

    @implementation RootViewController

    @synthesize permissions;
    @synthesize backgroundImageView;
    @synthesize menuTableView;
    @synthesize mainMenuItems;
    @synthesize headerView;
    @synthesize nameLabel;
    @synthesize profilePhotoImageView;

    - (void)viewDidLoad
    {
        
    }
        
    - (void)dealloc {
        //[permissions release];
        //[backgroundImageView release];
        //[loginButton release];
        //[menuTableView release];
        //[mainMenuItems release];
        //[headerView release];
        //[nameLabel release];
        //[profilePhotoImageView release];
        //[super dealloc];
    }

    - (void)didReceiveMemoryWarning {
        // Releases the view if it doesn't have a superview.
        [superdidReceiveMemoryWarning];
        
        // Release any cached data, images, etc that aren't in use.
    }

    #pragma mark - Facebook API Calls
    /**
     * Make a Graph API Call to get information about the current logged in user.
     */
    - (void)apiFQLIMe {
        // Using the "pic" picture since this currently has a maximum width of 100 pixels
        // and since the minimum profile picture size is 180 pixels wide we should be able
        // to get a 100 pixel wide version of the profile picture
        NSMutableDictionary*params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
                                       @"SELECT uid, name, pic FROM user WHERE uid=me()", @"query",
                                       nil];
        ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate];
        [[delegate facebook] requestWithMethodName:@"fql.query"
                                         andParams:params
                                     andHttpMethod:@"POST"
                                       andDelegate:self];
    }

    - (void)apiGraphUserPermissions {
        ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate];
        [[delegate facebook] requestWithGraphPath:@"me/permissions"andDelegate:self];
    }

    #pragma - Private Helper Methods

    /**
     * Show the logged in menu
     */

    - (void)showLoggedIn {
        [self.navigationControllersetNavigationBarHidden:NOanimated:NO];
        
        self.backgroundImageView.hidden= YES;
        loginButton.hidden= YES;
        self.menuTableView.hidden= NO;
        
        [selfapiFQLIMe];
    }

    /**
     * Show the logged in menu
     */

    - (void)showLoggedOut {
        [self.navigationControllersetNavigationBarHidden:YESanimated:NO];
        
        self.menuTableView.hidden= YES;
        self.backgroundImageView.hidden= NO;
        loginButton.hidden= NO;
        
        // Clear personal info
        nameLabel.text = @"";
        // Get the profile image
        [profilePhotoImageViewsetImage:nil];
        
        [[selfnavigationController] popToRootViewControllerAnimated:YES];
    }

    /**
     * Show the authorization dialog.
     */
    - (void)login {
        ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate];
        if (![[delegate facebook] isSessionValid]) {
            [[delegate facebook] authorize:permissions];
        } else {
            [self showLoggedIn];
        }
    }

    /**
     * Invalidate the access token and clear the cookie.
     */
    - (void)logout {
        ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate];
        [[delegate facebook] logout];
    }

    /**
     * Helper method called when a menu button is clicked
     */
    - (void)menuButtonClicked:(id)sender {
        // Each menu button in the UITableViewController is initialized
        // with a tag representing the table cell row. When the button
        // is clicked the button is passed along in the sender object.
        // From this object we can then read the tag property to determine
        // which menu button was clicked.
        //ImportPicViewController *controller = [[ImportPicViewController alloc]
        //                                      initWithIndex:[sender tag]];
        //pendingApiCallsController = controller;
        //[self.navigationController pushViewController:controller animated:YES];
        //[controller release];
    }

    #pragma mark - View lifecycle
    // Implement loadView to create a view hierarchy programmatically, without using a nib.
    - (void)loadView {
        UIView *view = [[UIView alloc] initWithFrame:[UIScreen
                                                      mainScreen].applicationFrame];
        [view setBackgroundColor:[UIColorwhiteColor]];
        self.view = view;
        //[view release];
        
        // Initialize permissions
        permissions= [[NSArrayalloc] initWithObjects:@"offline_access", nil];
        
        // Main menu items
        mainMenuItems= [[NSMutableArrayalloc] initWithCapacity:1];
        ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate];
        //NSArray *apiInfo = [[delegate apiData] apiConfigData];
        //for (NSUInteger i=0; i < [apiInfo count]; i++) {
        //    [mainMenuItems addObject:[[apiInfo objectAtIndex:i] objectForKey:@"title"]];
        //}
        
        // Set up the view programmatically
        self.view.backgroundColor= [UIColorwhiteColor];
        
        self.navigationItem.title= @"Hackbook for iOS";
        
        //self.navigationItem.backBarButtonItem =
        /*[[[UIBarButtonItem alloc] initWithTitle:@"Back"
                                          style:UIBarButtonItemStyleBordered
                                         target:nil
                                         action:nil] autorelease];*/
        
        // Background Image
        /*backgroundImageView = [[UIImageView alloc]
                               initWithFrame:CGRectMake(0,0,
                                                        self.view.bounds.size.width,
                                                        self.view.bounds.size.height)];*/
        [backgroundImageViewsetImage:[UIImageimageNamed:@"Default.png"]];
        //[backgroundImageView setAlpha:0.25];
        [self.viewaddSubview:backgroundImageView];
        
        // Login Button
        //loginButton = [[UIButton buttonWithType:UIButtonTypeCustom] ];
        /*CGFloat xLoginButtonOffset = self.view.center.x - (318/2);
        CGFloat yLoginButtonOffset = self.view.bounds.size.height - (58 + 13);
        loginButton.frame = CGRectMake(xLoginButtonOffset,yLoginButtonOffset,318,58);
        [loginButton addTarget:self
                        action:@selector(login)
              forControlEvents:UIControlEventTouchUpInside];
        [loginButton setImage:
         [UIImage imageNamed:@"FBConnect.bundle/images/<LoginWithFacebookNormal...>"]
                     forState:UIControlStateNormal];
        [loginButton setImage:
         [UIImage imageNamed:@"FBConnect.bundle/images/<LoginWithFacebookPressed...>"]
                     forState:UIControlStateHighlighted];
        [loginButton sizeToFit];
        [self.view addSubview:loginButton];*/
        
        // Main Menu Table
        /*menuTableView = [[UITableView alloc] initWithFrame:self.view.bounds
                                                     style:UITableViewStylePlain];
        [menuTableView setBackgroundColor:[UIColor whiteColor]];
        menuTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        menuTableView.autoresizingMask =  UIViewAutoresizingFlexibleWidth;
        menuTableView.dataSource = self;
        menuTableView.delegate = self;
        menuTableView.hidden = YES;*/
        //[self.view addSubview:menuTableView];
        
        // Table header
        /*headerView = [[UIView alloc]
                      initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 100)];
        headerView.autoresizingMask =  UIViewAutoresizingFlexibleWidth;
        headerView.backgroundColor = [UIColor whiteColor];
        CGFloat xProfilePhotoOffset = self.view.center.x - 25.0;
        profilePhotoImageView = [[UIImageView alloc]
                                 initWithFrame:CGRectMake(xProfilePhotoOffset, 20, 50, 50)];
        profilePhotoImageView.autoresizingMask =  UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
        [headerView addSubview:profilePhotoImageView];
        nameLabel = [[UILabel alloc]
                     initWithFrame:CGRectMake(0, 75, self.view.bounds.size.width, 20.0)];
        nameLabel.autoresizingMask =  UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
        nameLabel.textAlignment = UITextAlignmentCenter;
        nameLabel.text = @"";
        [headerView addSubview:nameLabel];
        menuTableView.tableHeaderView = headerView;*/
        
        //[self.view addSubview:menuTableView];
        
        pendingApiCallsController= nil;
    }

    - (void)viewDidUnload {
        [superviewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }

    - (void)viewWillAppear:(BOOL)animated {
        //[self.navigationController setNavigationBarHidden:YES animated:animated];
        [super viewWillAppear:animated];
        
        ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate];
        if (![[delegate facebook] isSessionValid]) {
            [selfshowLoggedOut];
        } else {
            [self showLoggedIn];
        }
    }

    - (void)viewWillDisappear:(BOOL)animated {
        [self.navigationControllersetNavigationBarHidden:NOanimated:animated];
        [super viewWillDisappear:animated];
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        returnYES;
    }

    #pragma mark - UITableViewDatasource and UITableViewDelegate Methods

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return 60.0;
    }

    // Customize the number of sections in the table view.
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return[mainMenuItemscount];
    }

    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier ];
            cell.selectionStyle= UITableViewCellSelectionStyleNone;
        }
        
        //create the button
        /*UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        button.frame = CGRectMake(20, 20, (cell.contentView.frame.size.width-40), 44);
        button.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;
        [button setBackgroundImage:[[UIImage imageNamed:@"MenuButton.png"]
                                    stretchableImageWithLeftCapWidth:9 topCapHeight:9]
                          forState:UIControlStateNormal];
        [button setTitle:[mainMenuItems objectAtIndex:indexPath.row]
                forState:UIControlStateNormal];
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(menuButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
        button.tag = indexPath.row;
        [cell.contentView addSubview:button];*/
        
        return cell;
    }

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        
    }

    - (void)storeAuthData:(NSString *)accessToken expiresAt:(NSDate *)expiresAt {
        NSUserDefaults*defaults = [NSUserDefaultsstandardUserDefaults];
        [defaults setObject:accessToken forKey:@"FBAccessTokenKey"];
        [defaults setObject:expiresAt forKey:@"FBExpirationDateKey"];
        [defaults synchronize];
    }

    #pragma mark - FBSessionDelegate Methods
    /**
     * Called when the user has logged in successfully.
     */

    - (void)fbDidLogin {
        [selfshowLoggedIn];
        ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate]; 
        //ImagePicAppDelegate *delegate = (ImagePicAppDelegate *)[[UIApplication sharedApplication] delegate];
        [selfstoreAuthData:[[delegate facebook] accessToken] expiresAt:[[delegate facebook] expirationDate]];
        NSLog(@"Permissions granted.");
        
        //[pendingApiCallsController userDidGrantPermission];
    }

    -(void)fbDidExtendToken:(NSString *)accessToken expiresAt:(NSDate *)expiresAt {
        NSLog(@"token extended");
        [self storeAuthData:accessToken expiresAt:expiresAt];
    }

    /**
     * Called when the user canceled the authorization dialog.
     */

    -(void)fbDidNotLogin:(BOOL)cancelled {
        NSLog(@"permission not granted");
        //[pendingApiCallsController userDidNotGrantPermission];
    }

    /**
     * Called when the request logout has succeeded.
     */
    - (void)fbDidLogout {
        pendingApiCallsController= nil;
        
        // Remove saved authorization information if it exists and it is
        // ok to clear it (logout, session invalid, app unauthorized)
        NSUserDefaults*defaults = [NSUserDefaultsstandardUserDefaults];
        [defaults removeObjectForKey:@"FBAccessTokenKey"];
        [defaults removeObjectForKey:@"FBExpirationDateKey"];
        [defaults synchronize];
        
        [selfshowLoggedOut];
    }

    /**
     * Called when the session has expired.
     */
    - (void)fbSessionInvalidated {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Auth Exception"
                                  message:@"Your session has expired."
                                  delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil,
                                  nil];
        [alertView show];
        //[alertView release];
        [selffbDidLogout];
    }

    #pragma mark - FBRequestDelegate Methods
    /**
     * Called when the Facebook API request has returned a response.
     *
     * This callback gives you access to the raw response. It's called before
     * (void)request:(FBRequest *)request didLoad:(id)result,
     * which is passed the parsed response object.
     */
    - (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
        //NSLog(@"received response");
    }

    /**
     * Called when a request returns and its response has been parsed into
     * an object.
     *
     * The resulting object may be a dictionary, an array or a string, depending
     * on the format of the API response. If you need access to the raw response,
     * use:
     *
     * (void)request:(FBRequest *)request
     *      didReceiveResponse:(NSURLResponse *)response
     */
    - (void)request:(FBRequest *)request didLoad:(id)result {
        if ([result isKindOfClass:[NSArray class]]) {
            result = [result objectAtIndex:0];
        }
        // This callback can be a result of getting the user's basic
        // information or getting the user's permissions.
        if ([result objectForKey:@"name"]) {
            // If basic information callback, set the UI objects to
            // display this.
            nameLabel.text = [result objectForKey:@"name"];
            // Get the profile image
            UIImage*image = [UIImageimageWithData:[NSDatadataWithContentsOfURL:[NSURLURLWithString:[result objectForKey:@"pic"]]]];
            
            // Resize, crop the image to make sure it is square and renders
            // well on Retina display
            float ratio;
            float delta;
            floatpx = 100; // Double the pixels of the UIImageView (to render on Retina)
            CGPoint offset;
            CGSize size = image.size;
            if (size.width > size.height) {
                ratio = px / size.width;
                delta = (ratio*size.width - ratio*size.height);
                offset = CGPointMake(delta/2, 0);
            } else {
                ratio = px / size.height;
                delta = (ratio*size.height - ratio*size.width);
                offset = CGPointMake(0, delta/2);
            }
            CGRect clipRect = CGRectMake(-offset.x, -offset.y,
                                         (ratio * size.width) + delta,
                                         (ratio * size.height) + delta);
            UIGraphicsBeginImageContext(CGSizeMake(px, px));
            UIRectClip(clipRect);
            [image drawInRect:clipRect];
            UIImage*imgThumb = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();
            [profilePhotoImageView setImage:imgThumb];
            
            [selfapiGraphUserPermissions];
        } else {
            // Processing permissions information
            ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate];
            [delegate setUserPermissions:[[result objectForKey:@"data"] objectAtIndex:0]];
        }
    }

    /**
     * Called when an error prevents the Facebook API request from completing
     * successfully.
     */
    - (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
        NSLog(@"Err message: %@", [[error userInfo] objectForKey:@"error_msg"]);
        NSLog(@"Err code: %d", [error code]);
    }

    @end

    *****************************This is from RootVC.h
    #import <UIKit/UIKit.h>
    #import "ImportPicViewController.h"
    #import "FBConnect.h"

    @interface RootViewController : UIViewController
    <FBRequestDelegate,
    FBDialogDelegate,
    FBSessionDelegate,
    UITableViewDataSource,
    UITableViewDelegate>{
        NSArray *permissions;

        UIImageView *backgroundImageView;
        UIButton *loginButton;
        UITableView *menuTableView;

        NSMutableArray *mainMenuItems;

        UIView *headerView;
        UILabel *nameLabel;
        UIImageView *profilePhotoImageView;
        
        ImportPicViewController *pendingApiCallsController;
    }

    @property(nonatomic, retain) NSArray*permissions;
    @property (nonatomic, retain) UIImageView *backgroundImageView;
    @property(nonatomic, retain) UITableView*menuTableView;
    @property(nonatomic, retain) NSMutableArray*mainMenuItems;
    @property(nonatomic, retain) UIView*headerView;
    @property(nonatomic, retain) UILabel*nameLabel;
    @property (nonatomic, retain) UIImageView *profilePhotoImageView;

    @end

    **********************************This is from ImportPicVC, which is tied to my only storyboard VC
    #import "ImportPicViewController.h"
    #import "RootViewController.h"
    #import "ImportPicAppDelegate.h"//MDC new

    @interfaceImportPicViewController()
    @property (nonatomic, strong) NSMutableArray * myData;
    @end

    @implementation ImportPicViewController
    @synthesize myData = _myData;
    @synthesize currentAPICall = _currentAPICall;

    - (void)viewDidLoad
    {
        [superviewDidLoad];
        //[self application:(UIApplication *)application openURL:(NSURL *)url
        //sourceApplication:(NSString *)sourceApplication annotation:(id)annotation ];
        //[delegate facebook] = [[Facebook alloc] initWithAppId:@"224207854355440" andDelegate:self];
        //[facebook handleOpenURL:url];
        ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate]; //MDC new
        NSUserDefaults*defaults = [NSUserDefaultsstandardUserDefaults];
        if ([defaults objectForKey:@"FBAccessTokenKey"] 
            && [defaults objectForKey:@"FBExpirationDateKey"]) {
            [delegate facebook].accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
            [delegate facebook].expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
        }
        if (![[delegate facebook] isSessionValid]) {
            [[delegate facebook] authorize:nil];
        }
    }

    /*
    -(void)postToWall
    {
        ImportPicAppDelegate *delegate = (ImportPicAppDelegate *)[[UIApplication sharedApplication] delegate];
        if(delegate.facebook.isSessionValid) {
            [self doPost:nil];
        }else {
            //we're not logged in so call the login and then do the post when it's done
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doPost:) name:@"FBLoginComplete" object:nil];
        }
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"offline_access",
                                @"publish_stream",
                                nil];
        [delegate.facebook authorize:permissions];
    }

    -(void)doPost:(NSNotification *) notification
    {
        ImportPicAppDelegate *delegate = (ImportPicAppDelegate *)[[UIApplication sharedApplication] delegate];
        if (delegate.facebook.isSessionValid) {
            if ([[delegate userPermissions] objectForKey:@"photo_upload"]) { 
                //we're where we need to be with permissions//[self apiGraphUserPhotosPost]; //MDC
                NSLog(@"That's nice. Nothing to change.");
            } else {
                //add needed permissions, with prompt
                //currentAPICall = kDialogPermissionsCheckinForRecent; //done already
                [self apiPromptPhotoAddPermissions]; //MDC
            }
            // Download a sample photo ??MDC - sub my photo in here later
            NSURL *url = [NSURL URLWithString:@"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"];
            NSData *data = [NSData dataWithContentsOfURL:url];
            UIImage *img  = [[UIImage alloc] initWithData:data];
            NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
               img, @"picture", nil];
        }
    }
     8/

    /*
     * Dialog: Authorization to grant the app photo add permissions. - MDC
     */
    - (void)apiPromptPhotoAddPermissions { 
        ImportPicAppDelegate*delegate = (ImportPicAppDelegate*)[[UIApplicationsharedApplication] delegate];
        NSArray*photoAddPermissions = [[NSArrayalloc] initWithObjects:@"publish_stream", @"publish_actions", @"photo_upload", nil]; //MDC
        [[delegate facebook] authorize:photoAddPermissions];
        //[photoAddPermissions release];
    }

    - (void)viewDidUnload
    {
        [superviewDidUnload];
        // Release any retained subviews of the main view.
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        if([[UIDevicecurrentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            return(interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
        } else {
            return YES;
        }
    }
    @end

    ***********************************This is the ImportPicVC.h
    #import <UIKit/UIKit.h>
    #import "FBConnect.h"

    typedef enum apiCall {
        kAPILogout,
        kAPIGraphUserPermissionsDelete,
        kDialogPermissionsExtended,
        kDialogRequestsSendToMany,
        kAPIGetAppUsersFriendsNotUsing,
        kAPIGetAppUsersFriendsUsing,
        kAPIFriendsForDialogRequests,
        kDialogRequestsSendToSelect,
        kAPIFriendsForTargetDialogRequests,
        kDialogRequestsSendToTarget,
        kDialogFeedUser,
        kAPIFriendsForDialogFeed,
        kDialogFeedFriend,
        kAPIGraphUserPermissions,
        kAPIGraphMe,
        kAPIGraphUserFriends,
        kDialogPermissionsCheckin,
        kDialogPermissionsCheckinForRecent,
        kDialogPermissionsCheckinForPlaces,
        kAPIGraphSearchPlace,
        kAPIGraphUserCheckins,
        kAPIGraphUserPhotosPost,
        kAPIGraphUserVideosPost,
    } apiCall;

    @interfaceImportPicViewController : UIViewController<FBRequestDelegate>//<FBSessionDelegate, FBDialogDelegate>{
        //Facebook *facebook;
    //}
    @property(nonatomic) intcurrentAPICall;
    @end

    **********************************
previous month may 2012 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today