2014-03-07 34 views
0

我將一列收藏夾 - 從詳細信息視圖 - 傳遞給(應該是)一個顯示收藏夾的表視圖。 第一個數組[在第一視圖]是好的:數組對象正在加載但未連接到單元格

Array found. Contents: (
    "\U5df4", 
    "\U5df4", 
    "\U82ad\U8305//\U5df4\U8305", 
    "\U5df4\U5bb6", 
    "\U7b06\U7bd3\U513f", 
    "\U5df4", 
    "\U5df4", 
    "\U5df4", 
    "\U5df4", 
    "\U5df4", 
    "\U5df4\U5bb6", 
    "\U5df4", 
    "\U5df4", 
    "\U5df4" 
) 
Number of items in my array is: 15 

和[在第二視圖從所述第二陣列]在打印:

Printing description of self->FavsTwo: 
<__NSCFArray 0x1f9644a0>(
巴, 
巴, 
芭茅//巴茅, 
巴家, 
笆簍兒, 
巴, 
巴, 
巴, 
巴, 
巴, 
巴家, 
巴, 
巴, 
巴, 
巴家 
) 

還爽...

首破我得到的是在這裏:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [FavsTwo count]; 
} 

,然後所有這些錯誤:

*** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:6235 
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' 
*** 

我的手機是這樣的:

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

{ 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    NSString *cellValue = [self.FavsTwo objectAtIndex:indexPath.row]; 
    cell.textLabel.text = cellValue; 
    return cell; 


} 

試圖將對象轉換爲字符串 - 真的不知道在那裏它的失敗

歡呼

+0

你得到解決? –

+0

@Himanshu Joshi都在下面的工作來加載表,但我仍然在行數崩潰 - 返回[FavsTwo計數]; * FIRST *單擊繼續在調試獲取它加載.... – user3306356

+0

你記錄'[FavsTwo計數];'? –

回答

1

你缺少自我dequeueReusableCellWithIdentifier:可能返回nil,如果它不能deque的細胞。

您需要檢查,如果該細胞是nil

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if(!cell) { 
     cell = [UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] 
    }  

    NSString *cellValue = [self.FavsTwo objectAtIndex:indexPath.row]; 
    cell.textLabel.text = cellValue; 

    return cell; 
} 

如果你已經使用registerClass:forCellReuseIdentifier:registerNib:forCellReuseIdentifier: .The你需要dequeueReusableCellWithIdentifier:forIndexPath:獲得細胞:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    NSString *cellValue = [self.FavsTwo objectAtIndex:indexPath.row]; 
    cell.textLabel.text = cellValue; 

    return cell; 
} 
+0

這工作來加載表,但我仍然在行數崩潰 - 返回[FavsTwo計數]; * FIRST *單擊繼續在調試獲取它加載.... – user3306356

+0

@ user3306356更新我的答案,也在Objectics-C不是不常見的啓動與國會大廈的任何變量,所以'self.FavsTwo'應該是' self.favsTwo'。 – rckoenes

+0

必須具有投擲它的大小寫......現在工作! – user3306356

2

的cellForRowAtIndexPath回報爲零,如果不能ReusableCell,您應該創建一個單元格,其格式爲CellIdentifier

試試這個:在tableView:numberOfRowsInSection:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [self.FavsTwo count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
    } 
    NSString *cellValue = [self.FavsTwo objectAtIndex:indexPath.row]; 
    cell.textLabel.text = cellValue; 

    return cell; 
} 
+0

這工作來加載表,但我仍然崩潰的行數 - 返回[FavsTwo計數]; * FIRST *單擊繼續在調試獲取它加載.... – user3306356

+0

@ user3306356你能列出關於'返回[FavsTwo計數]' – simalone

+0

崩潰信息一定是rckoenes的關於它的大寫的評論...謝謝儘管你的幫助! – user3306356

相關問題