0

OK、それでここで私は再び恐ろしいことに直面していmessage sent to deallocated instanceます...

  • DMTabBar(基本的にはXcodeのようなTabBarコントロール)を使用しています
  • ARCが有効になっている

さて、これが取引です:

  • コントロールに付随する例は正常に機能します
  • 私はゾンビを有効にしました(そして、Instrumentsを使用してデバッグを試みましたが、正直なところ、何を探すべきかわかりません)
  • deallocatedインスタンスはtabBarItems、TabBar(さまざまなボタンをホストするもの)の配列です。

これは私がアイテムを追加する方法です:

NSMutableArray* sidebarItems = [@[
        [DMTabBarItem tabBarItemWithIcon:[NSImage templateImageNamed:@"One" withSize:iconSize] tag:0 tooltip:@"Files"],
        [DMTabBarItem tabBarItemWithIcon:[NSImage templateImageNamed:@"Two" withSize:iconSize] tag:1 tooltip:@"Explorer"],
        [DMTabBarItem tabBarItemWithIcon:[NSImage templateImageNamed:@"Three" withSize:iconSize] tag:2 tooltip:@"Bookmarks"],
        [DMTabBarItem tabBarItemWithIcon:[NSImage templateImageNamed:@"Four" withSize:iconSize] tag:3 tooltip:@"Search"]
    ] mutableCopy];

[sidebarTabs setTabBarItems:items];

// Handle selection events
[sidebarTabs handleTabBarItemSelection:^(DMTabBarItemSelectionType selectionType, DMTabBarItem *targetTabBarItem, NSUInteger targetTabBarItemIndex) {
        if (selectionType == DMTabBarItemSelectionType_WillSelect) {
            [sidebarTabView selectTabViewItem:[sidebarTabView.tabViewItems objectAtIndex:targetTabBarItemIndex]];
        } else if (selectionType == DMTabBarItemSelectionType_DidSelect) {
        }
    }];

これは、さまざまな要素が宣言される方法です。

@interface myAppl : NSWindowController
{
    IBOutlet DMTabBar* sidebarTabs;
    IBOutlet NSTabView* sidebarTabView;
} 

そしてこれはDMTabBarのインターフェースです(最も「重要な」部分):

@interface DMTabBar : NSView {

}

// set an NSArray of DMTabBarItem elements to populate the DMTabBar
@property (nonatomic,strong) NSArray*           tabBarItems;

// change selected item by passing a DMTabBarItem object (ignored if selectedTabBarItem is not contained inside tabBarItems)
@property (nonatomic,assign) DMTabBarItem*      selectedTabBarItem;

私が間違っているのは何なのか説明してもらえますか?私は間違いなくメモリ管理の第一人者ではありませんが(そうです、勉強していることは認めます)、これで間違いなく自殺するつもりです...

私は設定しています、tabBarItemsそして彼らはそこにいるようです(少なくとも最初は)。なぜリリースされるのですか?(制御コードとプロジェクトコードの両方がARCを使用することを忘れないでください)。

何か案は?(他に何か知る必要がある場合に備えて、私に知らせてください...)

4

2 に答える 2

1

通常のメモリ デバッグ手法で実行してみましたか。つまり、

  • ゾンビの楽器、および
  • Xcode の[スキームの編集] > [診断] > [メモリ管理] タブでさまざまなフラグを設定しますか?
于 2013-02-26T06:57:11.697 に答える