2010-05-14 65 views
1

我看到下面的錯誤在我的應用程序:爲什麼我被告知在malloc_error_break上設置斷點?

(4446,0xa0bc94e0)的malloc:*錯誤對象0x1d153000:指針 被釋放沒有被分配 *在malloc_error_break設置一個斷點調試

這個錯誤是什麼意思?

我想顯示在表視圖中2000個地址,和我看到的錯誤在下面的代碼的cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 


    } 

    obdata = [AddressBookData alloc]; 
    obdata = [arrayLocalAddressbook objectAtIndex:indexPath.row]; 
    // Set button Tag 

    cell.textLabel.text = [NSString stringWithString:obdata.lastname]; 

    return cell; 



} 

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

} 



// Customize the number of rows in the table view. 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 

    return [arrayLocalAddressbook count]; 

} 

可能是什麼造成的?

+0

可能與http://stackoverflow.com/questions/7796921/malloc-error-break-breakpoint-not-working – paulmelnikow 2012-03-05 02:32:26

+0

刪除safari檢查http://stackoverflow.com/a/43885754/6521116 – 2017-05-10 07:19:42

回答

1

該應用程序給你提示如何繼續:在malloc_error_break設置斷點。當你到達那裏時,檢查應用程序的回溯。你可能會發現你過度釋放一個對象或者持有一個陳舊的指針。

0

兩個奇怪的事情:

obdata = [AddressBookData alloc]; 

你不是這個對象調用的init - 在OBJ-C,你通常有頁頭-INIT在一起。

obdata = [arrayLocalAddressbook objectAtIndex:indexPath.row]; 

然後你立即分配別的東西給這個變量,所以第一個AddressBookData永遠不會被使用。

相關問題