2012-10-17 32 views
0

我得到一個錯誤任何一個可以幫助我解決這個線程1:信號SIGABRT

線程1:信號SIGABRT

這是代碼

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

    /* FOR SIMPLE CELL */ 
    static NSString *MyIdentifier = @"MyCell"; 

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]; 


    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 
    word *worddc = [Array objectAtIndex:[indexPath row]]; //ERROR thread 1 signal SIGABRT 

     cell.textLabel.text = worddc.word_alphabet; 



    return cell; 
} 
+1

我們需要更多的幫助。爲什麼這個代碼有用?你想用它做什麼? *線程1:信號SIGABRT *非常非常普遍,如果不提供更多信息,根本無濟於事。 – rdurand

+1

您應該大寫類(「Word」)和小寫變量(「數組」)。 – Eiko

+0

我想它必須是內存管理問題。你確定Array是一個有效的參考嗎?它可能已被釋放。 –

回答

0

檢查以下列表:

  • 檢查A rray仍然被分配,並且不被釋放。
  • 嘗試投這樣的值:

    word *worddc = (word *)[Array objectAtIndex:[indexPath row]]; 
    
+1

該死!同樣的答案,遲到15秒,lol – rdurand

+0

我做了同樣的錯誤:( –

+0

@EngineerUet檢查你的數組是否被分配到任何地方?大多數情況下,它應該分配在viewDidLoad。 –

0

我評論說,你需要解釋一下你的問題,但我可能有一個想法,反正:

objectAtIndex:返回(ID)對象。嘗試將結果轉換爲文字*:

word *worddc = (word*)[Array objectAtIndex:[indexPath row]]; 
+0

謝謝[tableview reloadData]; –

0

試試這種方式並檢查您在strObj中獲得的是字符串嗎?

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

    /* FOR SIMPLE CELL */ 
    static NSString *MyIdentifier = @"MyCell"; 

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

    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 
    word *worddc = [Array objectAtIndex:[indexPath row]]; //ERROR thread 1 signal SIGABRT 
    NSString *strObj=worddc.word_alphabet; 
    cell.textLabel.text =strObj;//Here check what you are getting by setting breakpoint. 
    strObj=nil; 



    return cell; 
} 
相關問題