私はNSMustableArrayで間違っていることを解決できません。私はメモリ割り当てをよく理解していないと言っても間違いないので、単純な質問であれば謝ります。割り当てが解除されたNSMutableArray?
私はタブバーアプリケーションがうまく動作しており、タブバーの1つに人の正面図と背面図があります。 IBActionsでNSLogsは、両方のことを私に言っている私はなぜ
@interface BurnsCalculatorViewController : UIViewController// <UIPickerViewDelegate, UIPickerViewDataSource>
{
UIView *frontView;
UIView *backView;
UIButton *frontButton;
UIButton *backButton;
NSMutableArray *frontBurnsArray;
}
@property (nonatomic, retain) UIView *frontView;
@property (nonatomic, retain) UIView *backView;
@property (nonatomic, retain) UIButton *frontButton;
@property (nonatomic, retain) UIButton *backButton;
@property (nonatomic, retain) NSMutableArray *frontBurnsArray;
-(IBAction)frontButtonSelect:(id)sender;
-(IBAction)backButtonSelect:(id)sender;
@end
は、その後、私は私が把握することはできません何の.mファイル
@implementation BurnsCalculatorViewController
@synthesize frontView;
@synthesize backView;
@synthesize frontButton;
@synthesize backButton;
@synthesize frontBurnsArray;
-(IBAction)frontButtonSelect:(id)sender
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[self view] cache:YES];
[self.view addSubview:backView];
[self.view addSubview:backButton];
[UIView commitAnimations];
NSLog(@"%@", frontBurnsArray);
}
-(IBAction)backButtonSelect:(id)sender
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[self view] cache:YES];
[self.view addSubview:frontView];
[self.view addSubview:frontButton];
[UIView commitAnimations];
NSLog(@"%@", frontBurnsArray);
}
-(void)viewDidLoad
{
frontBurnsArray = [NSMutableArray arrayWithObjects: @"frontHead", @"frontChest", @"frontAbdomen", @"frontGroin",@"frontLeftArm", @"frontLeftForeArm", @"frontRightArm", @"frontRightForearm", @"frontLeftThigh", @"frontLeftLowerLeg", @"frontRightThigh", @"frontRightLowerLeg",nil];
CGRect viewframe = CGRectMake(0, 0, 320, 480);
frontView = [[UIView alloc] initWithFrame:viewframe];
frontView.backgroundColor = [UIColor blueColor];
[self.view addSubview:frontView];
frontButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[frontButton addTarget:self action:@selector(frontButtonSelect:) forControlEvents:UIControlEventTouchDown];
[frontButton setTitle:@"Show Back" forState:UIControlStateNormal];
frontButton.frame = CGRectMake(210, 10, 100, 30);
[self.view addSubview:frontButton];
backView = [[UIView alloc] initWithFrame:viewframe];
backView.backgroundColor = [UIColor blackColor];
backButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
[backButton addTarget:self action:@selector(backButtonSelect:)forControlEvents:UIControlEventTouchDown];
[backButton setTitle:@"Show Front" forState:UIControlStateNormal];
backButton.frame = CGRectMake(210, 10, 100, 30);
}
-(void)dealloc
{
[super dealloc];
[frontButton release];
[backButton release];
[frontBurnsArray release];
}
@end
を持っていた.hで
ですインスタンスの割り当てが解除されました。 deallocの「リリース」は別として、配列を保持すると言いましたが、他の場所でリリースしていません。
私は年を費やしてこれに対する答えを探しましたが、それを理解できません。
ありがとうございます!あなたが保持性
を使用していない
呼び出すことができます:[ココアのコアコンピタンス:メモリ管理](http://developer.apple.com/library/mac/#documentation/General/Conceptual/DevPedia- CocoaCore/MemoryManagement.html#// apple_ref/doc/uid/TP40008195-CH27-SW1) – Jay