2015-04-17 30 views
1

終止應用程序因未捕獲的異常[<__ NSCFString 0x7f8392695300> valueForUndefinedKey:]:該類不是密鑰名稱的密鑰值編碼。

NSUnknownKeyException '原因:'[< __NSCFString 0x7f8392695300> valueForUndefinedKey:]:這個類不是密鑰值編碼兼容的鍵名稱。

得到一個例外..我想顯示數據庫值泰伯維

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

    NSInteger indexOfFirstname = [self.dbManager.arrColumnNames indexOfObject:@"name"]; 

    NSInteger indexOfLastname = [self.dbManager.arrColumnNames indexOfObject:@"fname"]; 
    cell.textLabel.text = [NSString stringWithFormat:@ "%@ %@", [[self.arrPeopleInfo objectAtIndex:indexPath.row]valueForKey:@"name"], [[self.arrPeopleInfo objectAtIndex:indexPath.row] valueForKey:@"fname"]]; 
+0

只是檢查你是否已經正確地將tableview設置爲同一類,數據源和委託以及 – channi

+0

順便說一句你如何初始化UITableViewCell? 只需檢查NSInteger行上的斷點,如果單元格爲零 – channi

回答

0

的錯誤意味着你的表視圖不鍵值兼容,這意味着KVP的(關鍵 - 價值對)爲不可用爲該類型的對象。

+0

我如何移除此錯誤? –

+0

如果可以,請使用**方法**更改值。我不知道具體細節,因爲我不經常使用表和數據庫。我會與王子的回答上面。 – DDPWNAGE

1

遵循以下步驟:

1)進入課堂xib文件,或如果在storyboard

2)UITableView點擊右鍵,remove所有早期bindings

3)添加新的約束提供IBOutlet,delegatedatasource

4)Cleanproject並再次運行。

0

檢查你的故事板n清除警告。應該有一些連接錯誤或警告in your case there will be some yellow marks, clear it n see

在你的情況下會出現一些黃色標記,清除它看到。它會工作

+1

這就是我正在尋找的。做得好 ;) –

2
[self.arrPeopleInfo objectAtIndex:indexPath.row] 

返回一個字符串,那麼你嘗試調用「valueForKey:」對和串不給選擇作出迴應。檢查arrPeopleInfo的內容實際上是字典。

相關問題