//
//  PSItemViewController.m
//  ArmorP3V1
//

#import "PSItemViewController.h"
#import "PSItem.h"
#import "PSMutex.h"

@implementation PSItemViewController

-(id)initWithItem:(PSItem*)item {
    self = [super init];
    if (self) {
        _item = item;
        [_item retain];
    }else {
        [[PSMutex mainMutex] raiseMemoryError];
    }
    [[PSMutex mainMutex] showMemoryAlertIfError];
    return self;
}

-(void)loadView
{
    [super loadView];
    
    NSMutableString* string = [[NSMutableString alloc]init];
    [_item printContents:string];

    CGRect bounds = [[UIScreen mainScreen] applicationFrame];
    
    _textView = [[UITextView alloc]initWithFrame:bounds];
    _textView.editable = NO;
    _textView.text = string;
    self.view = _textView;
    [string release];
}

- (void)dealloc
{
    [_item release];
    [_textView release];
    [super dealloc];
}

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

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
