理解できない別の奇妙なバグがあります。
以下のコードで tableviewcell を作成しようとしています。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
TableViewCellController *cell = (TableViewCellController *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil];
cell = [_cell autorelease];
_cell = nil;
}
// Configure the cell...
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
Article *article = (Article *)[articles objectAtIndex: storyIndex];
cell.titleLabel.text = article.title;
cell.siteLabel.text = article.site.name;
cell.summaryLabel.text = article.description;
[article release];
return cell;
}
問題は、説明の値を除いて、ラベルに任意の値を設定できることです。それを行うとすぐに、次のクラッシュが発生します。
2010-12-22 16:07:13.165 iDoms[24086:207] CoreData: 注釈: 障害がデータベースから実行されました: 0x8b16dd0 プログラムがシグナルを受信しました: 「EXC_BAD_ACCESS」。警告: 以前に選択したフレームを復元できません。データ フォーマッターは一時的に利用できません。「続行」後に再試行します。(現時点で dlopen を呼び出すのは安全ではありません。)
スタックに 62820 の明細項目があります。私はこれを理解するためにどこから始めるべきか分かりません。私は Java に慣れており、Objective-C はこれまでのところ、小さな奇妙なバグに関しては本当に悪夢でした。
Article クラスは次のようになります。
// Article.h
#import <CoreData/CoreData.h>
@class Site;
@interface Article : NSManagedObject
{
}
@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSNumber * read;
@property (nonatomic, retain) NSString * link;
@property (nonatomic, retain) NSDate * pubDate;
@property (nonatomic, retain) NSString * description;
@property (nonatomic, retain) NSDate * lastUpdate;
@property (nonatomic, retain) Site * site;
@end
と
// Article.m
#import "Article.h"
@implementation Article
@dynamic id;
@dynamic title;
@dynamic read;
@dynamic link;
@dynamic pubDate;
@dynamic description;
@dynamic lastUpdate;
@dynamic site;
@end
データベースにはデータが含まれており、特定のフィールドには文字列 "Test1" だけが含まれています。いつものように、どんな助けも本当に感謝しています!