//
//  MovieViewController.m
//  Movie
//
//  Created by Bill Dudney on 4/29/09.
//  Copyright Gala Factory Software LLC 2009. All rights reserved.
//
//
//  Licensed with the Apache 2.0 License
//  http://apache.org/licenses/LICENSE-2.0
//

//START: code.MovieViewController02.import
#import "MovieViewController.h"
//START_HIGHLIGHT
#import "Movie.h"
//END_HIGHLIGHT
//END: code.MovieViewController02.import

@implementation MovieViewController
//START: code.MovieViewController02.synthesize
@synthesize titleLabel;
@synthesize boxOfficeGrossLabel;
@synthesize summaryLabel;
@synthesize movie;
//END: code.MovieViewController02.synthesize

//START: code.MovieViewController.m.edit
- (IBAction)edit {
  NSLog(@"edit method invoked");
}
//END: code.MovieViewController.m.edit

//START: code.MovieViewController02.viewDidLoad
- (void)viewDidLoad {
  [super viewDidLoad];
  Movie *newMovie = [[[Movie alloc] // <label id="code.MovieEditorVC.createmovie"/>
                     initWithTitle:@"Iron Man" 
                     boxOfficeGross:[NSNumber numberWithFloat:650000000.00] 
                     summary:@"Smart guy makes cool armor"] autorelease];
  self.movie = newMovie;
}
//END: code.MovieViewController02.viewDidLoad

//START: code.MovieViewController02.viewWillAppear
- (void)viewWillAppear:(BOOL)animated {
  [super viewWillAppear:animated];
  self.titleLabel.text = self.movie.title;
  NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
  [formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
  self.boxOfficeGrossLabel.text = 
  [formatter stringFromNumber:self.movie.boxOfficeGross];
  [formatter release];
  self.summaryLabel.text = self.movie.summary;
}
//END: code.MovieViewController02.viewWillAppear

- (void)dealloc {
  self.titleLabel = nil;
  self.boxOfficeGrossLabel = nil;
  self.summaryLabel = nil;
  self.movie = nil;
  [super dealloc];
}

@end
