簡體   English   中英

錯誤:無法識別的選擇器發送到實例

[英]Error: unrecognized selector sent to instance

我有一個自定義 object, 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

我的根視圖 controller 實現了cellForRowAtIndexPath:並從NSArray of Spaces中獲取:

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

這工作正常,我可以單擊 go 進入詳細視圖並返回列表,但是在表格視圖和詳細視圖之間來回單擊 5-6 次后,我在[[cell spaceName] setText:aSpace.spaceName];處收到錯誤[[cell spaceName] setText:aSpace.spaceName]; 這是

'-[__NSCFSet spaceName]: 無法識別的選擇器發送到實例 0x6047b90'"

請幫忙! 任何見解將不勝感激!

更新:

我仍然遇到同樣的錯誤,但我已將其范圍縮小到:

-我正在 didSelectRowAtIndexPath 上創建一個詳細視圖 controller... -詳細視圖被推送到視圖控制器並顯示正常,我還添加了一個后退按鈕。 - 詳細視圖加載信息並在計時器上刷新 - 按后退按鈕返回表格列表視圖

這是我的詳細視圖沒有從 memory 發布的問題,所以我在視圖之間來回的 go 越多,定時器同時關閉的次數就越多。 我向 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];

    }
}

如何強制從 memory 釋放詳細視圖?

謝謝

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

也許你的aSpace = [spaces objectAtIndex:[indexPath row]]; 沒有返回 Space object。 也許在您嘗試使用它之前,您會測試以確保使用if ([aSpace class] == [Spaces class])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM