Assignment 4 – Paparazzi part 1

This content has 13 years. Please, read this page keeping its age in your mind.

In winter 2009 – 2010 C193p iPhone application Development course we had the Paparazzi Part 1 Assignment. It was fairly static and you could follow many different implementations.  Personally I follow the concept of creating a mutable array to keep the photoItem objects.

My Appplication delegate is like:

 

//
//  PaparazziAppDelegate.h

#import <UIKit/UIKit.h>

@interface PaparazziAppDelegate : NSObject <UIApplicationDelegate> {
    UITabBarController *tabBarController;
    UINavigationController *contactsNavController;
    UINavigationController *recentNavController;

    NSMutableArray *arrayPhotos;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

//  PaparazziAppDelegate.m

#import "PaparazziAppDelegate.h"
#import "PersonListViewController.h"
#import "PhotoListViewController.h"
#import "PhotoItem.h"

@implementation PaparazziAppDelegate

@synthesize window=_window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    arrayPhotos = [[NSMutableArray alloc] init];
    [arrayPhotos addObject:[PhotoItem makePhotoItemWithPhoto:[UIImage imageNamed:@"Jessica.jpg"] name:@"Some face" photographer:@"Josh"]];
    [arrayPhotos addObject:[PhotoItem makePhotoItemWithPhoto:[UIImage imageNamed:@"Rihanna.jpg"] name:@"Some other face" photographer:@"Al"]];
    [arrayPhotos addObject:[PhotoItem makePhotoItemWithPhoto:[UIImage imageNamed:@"Miley.jpg"] name:@"Hello face" photographer:@"Josh"]];

    tabBarController = [[UITabBarController alloc] init];

    //First Navigation Controller
    contactsNavController = [[UINavigationController alloc] init];
    PersonListViewController *personListViewController = [[PersonListViewController alloc] initWithNibName:@"PersonListViewController" bundle:[NSBundle mainBundle]];
    [personListViewController setTitle:@"Contacts"];

    [personListViewController setPhotos:arrayPhotos];
    [contactsNavController pushViewController:personListViewController animated:NO];
    [personListViewController release];

    //Second Navigation Controller
    recentNavController = [[UINavigationController alloc] init];
    PhotoListViewController *recentListViewController = [[PhotoListViewController alloc] initWithNibName:@"PhotoListViewController" bundle:[NSBundle mainBundle]];
    [recentListViewController setTitle:@"Recent"];

    [recentListViewController setPhotosToDisplay:arrayPhotos];
    [recentNavController pushViewController:recentListViewController animated:NO];
    [recentListViewController release];

    [tabBarController setViewControllers:[NSArray arrayWithObjects:contactsNavController, recentNavController, nil]];

    [[self window] addSubview:[tabBarController view]];
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)dealloc
{
    [arrayPhotos release];
    [contactsNavController release];
    [recentNavController release];
    [tabBarController release];
    [_window release];
    [super dealloc];
}

@end

Hope to help…