特定のページだけ画面遷移するとおかしくなる

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
TEAS TEA

特定のページだけ画面遷移するとおかしくなる

#1

投稿記事 by TEAS TEA » 15年前

iPhoneアプリを開発しております。
x-code objective-c

こちらで特定のページに遷移した後に前のページに戻ると落ちてしまうソースがあります。
他のページでは問題ないのですがこのページに遷移した後に戻ると何故か落ちてしまします。

エラーコードをみてみたのですが
----------------------------------------------------------------
プログラムはシグナルを受信しました:“EXC_BAD_ACCESS”。
(gdb)
----------------------------------------------------------------
となっており何が原因かわかりませんでした・・・。
http://d.hatena.ne.jp/kacchi0516/20100212/1265906746
こちらのサイトに乗っている方法を試してみると
----------------------------------------------------------------
*** -[CALayer retain]: message sent to deallocated instance 0x6077490
----------------------------------------------------------------
とでました。retainは変数を保持する?為の関数のようなのですが
今まで使ったことがなく他のページでは落ちてないのでこれが原因かがわかりません。

コード:


#import "MelodyViewController01.h"
#import "MelodyViewController02.h"

@implementation MelodyViewController01

#pragma mark -
#pragma mark View lifecycle

- (void)viewDidLoad {
	
    [super viewDidLoad];
	data = [[NSMutableArray alloc] initWithObjects:
			@"白白白",
			@"青青青",
			nil];
	 
}

#pragma mark -
#pragma mark Table view data source

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


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [data count];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
	MelodyTableViewCell *cell = (MelodyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[MelodyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

	return cell;
}

#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	
	MelodyViewController02* viewActive;
	viewActive = [[MelodyViewController02 alloc] init];
	viewActive.melodyColor = [[NSString alloc] initWithString:[data objectAtIndex:indexPath.row]];
	[self.navigationController pushViewController:viewActive animated:YES];
	[viewActive release];
}

#pragma mark -
#pragma mark Memory management

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

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
//	[data release];
    [super dealloc];
}

@end
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [data count];
}
の return を0にすると落ちたりはしませんでした。

長々とすみません…。
どうやってもこの不具合が取れないので質問させて頂きました。

TEAS TEA

Re: 特定のページだけ画面遷移するとおかしくなる

#2

投稿記事 by TEAS TEA » 15年前

プロジェクトのクリーンなどもしてみましたがやはり落ちてしまいます。
下記のソースだけが原因ではないのでしょうか?

TEAS TEA

Re: 特定のページだけ画面遷移するとおかしくなる

#3

投稿記事 by TEAS TEA » 15年前

原因がわかりました。
こちらではなくオートリリースしたものを更にリリースしていた為おこっていました。
解決させていただきます。

Kameda

Re: 特定のページだけ画面遷移するとおかしくなる

#4

投稿記事 by Kameda » 15年前

iPad用のアプリを開発している者ですが、4時間以上悩んでいた問題がやっと解決できました。
自分の場合は、単純に「dealloc」内でreleaseしていた1行をコメントアウトするだけでした。
ありがとうございます。

TEAS TEA さんが書きました:原因がわかりました。
こちらではなくオートリリースしたものを更にリリースしていた為おこっていました。
解決させていただきます。

閉鎖

“C言語何でも質問掲示板” へ戻る