我在iOS的編程愛好者。編程時我總是遇到同樣的問題。 我認爲我不瞭解內存管理問題。 這是我的實際項目:
h文件:含 一個NSMutableArray的NSString的
NSMutableArray *pictureStrings;
@property (nonatomic,retain) NSMutableArray *pictureStrings;
在M文件
:
@synthesize pictureStrings;
,並在viewDidLoad方法
pictureStrings = [[NSMutableArray alloc] init];
dealloc方法
[pictureStrings release];
好的。我有一個異步URL請求它得到的值存儲到pictureStrings
[pictureStrings addObject:aString];
但 當我讀到cellForRowAtIndexPath方法中值像
if (pictureStrings != nil) {
cell.textLabel.text = [NSString stringWithFormat:@"%@", [pictureStrings objectAtIndex:indexPath.row]];
}
若干字符串,並在connectionDidFinishLoading委託方法工作
我的應用程序崩潰與消息:
*期限inating應用程序由於未捕獲的異常 'NSRangeException',原因是: '* - [NSMutableArray的objectAtIndex:]:索引0超越界限空陣'
哪裏是我的錯嗎? 請幫幫我!
你的,拉斐爾。 來自奧地利的問候
嗨,大家好:這是我的一個愚蠢的錯誤。你是對的。這不是內存管理問題。我的想法是,加載圖片的所有路徑,但僅顯示tableView中的前10個。所以錯誤被創建。 非常感謝! – Raphael 2012-01-10 12:34:23