2011-05-04 71 views
1

我有一個自定義對象,Spaces錯誤:無法識別的選擇發送到實例

#import "Spaces.h" 


@implementation Spaces 

@synthesize spaceName; 
@synthesize spaceUsers; 
@synthesize spaceIcon; 
@synthesize spaceID; 

@synthesize imageURLString; 


- (void)dealloc 
{ 
    [spaceName release]; 
    [spaceUsers release]; 
    [spaceIcon release]; 

    [imageURLString release]; 

    [super dealloc]; 
} 

@end 

我的根視圖控制器實現了從SpacesNSArray一個cellForRowAtIndexPath:和抓鬥:

[[cell spaceName] setText:aSpace.spaceName]; 
    [[cell spaceChatType] setText:@"People"]; 
    [[cell spaceActiveUsers] setText:aSpace.spaceUsers]; 

這工作正常我可以點擊進入詳細視圖並返回列表,但在表格視圖和詳細視圖之間可能有5-6次點擊之後,我在[[cell spaceName] setText:aSpace.spaceName];處得到一個錯誤,它是

'-[__NSCFSet spaceName]: unrecognized selector sent to instance 0x6047b90'"

請幫忙!任何見解將非常感激!

UPDATE:

我仍然得到同樣的錯誤,但我已經將範圍縮小到這一點:

- 我創建一個細節視圖控制器didSelectRowAtIndexPath方法... -The細節視圖被推送到視圖控制器並顯示正常,我也添加了一個後退按鈕。 -The詳細視圖加載信息,並刷新上-Pressing後退按鈕計時器 追溯到表列表視圖

這是我的詳細視圖不被從內存中釋放,因此我越來回走的問題在觀點之間,更多的定時器同時發生。我添加了一個檢查viewWillDisappear通過設置一個布爾值停止計時器。

我注意到詳細視圖不卸載...

從RootViewController的:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    //no longer on initial view 
    isinit = NO; 

    //hide keyboard 
    [spacesSearch resignFirstResponder]; 

    if (spaces != nil && spaces.count > 0) 
    { 
     //set back button reference 
     UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Spaces" style:UIBarButtonItemStylePlain target:self action:@selector(returnSpacesList:)]; 
     self.navigationItem.backBarButtonItem = backButton; 

     [backButton release]; 

     DetailViewController *details = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; 

     //Grab Data from selected Space object and pass to DetailViewController 
     Spaces *aSpace = nil; 
     if (tableView == self.searchDisplayController.searchResultsTableView) 
     { 
      if ([self.filteredListContent count] == 0) 
      { 
       //self.lastSearchText 
       NSLog(@"Create new space code!"); 
      } 
      else 
      { 
       aSpace = [self.filteredListContent objectAtIndex:indexPath.row]; 
      } 
     } 
     else 
     { 
      aSpace = [spaces objectAtIndex:[indexPath row]]; 
     } 

     //set title and display 
     self.navigationController.title = [NSString stringWithFormat:@"/%@/",aSpace.spaceName]; 

     //pass data 
     [details passedValue:aSpace.spaceID :aSpace.spaceName]; 

     [self.navigationController pushViewController:details animated:YES]; 

     [aSpace release]; 
     [details release]; 

    } 
} 

我怎麼能強制從內存中釋放的詳細視圖?

謝謝

+1

你可以顯示你的cellForRow ...方法的其餘部分嗎?它看起來像你的單元格超出了範圍,現在指針指向的內存不是你的單元格(在你的示例錯誤中指向一個__NSCFSet)。 – RickDT 2011-05-04 21:48:24

+0

您可能需要發佈一些更多的代碼才能獲得很好的幫助。對我來說,看起來你可能有內存泄漏,並且你的一些對象已經被釋放,但是很難從給出的信息中說出來。 – uvesten 2011-05-04 22:23:53

回答

1

聽起來像[cell spaceName]已被autoReleased。我看不出你是如何定義的,但看看你的代碼的那一部分。
如果您需要更多幫助,則需要提供更多代碼。

+0

內存泄漏導致autorelease,詳細視圖deloc在返回表視圖時未被調用,因爲我未能釋放一些數組變量,因此仍然在使用中。 – 2011-05-12 20:08:16

0

也許你aSpace = [spaces objectAtIndex:[indexPath row]]; 沒有返回一個空間物體。也許在你嘗試和使用它之前,你需要測試一下,以確定是否有類似if ([aSpace class] == [Spaces class])

相關問題