Objective c 调试';发送到解除分配实例的消息';

Objective c 调试';发送到解除分配实例的消息';,objective-c,cocoa,memory-management,automatic-ref-counting,Objective C,Cocoa,Memory Management,Automatic Ref Counting,好的,现在我再次面对发送给解除分配实例的可怕的消息 我正在使用(基本上是一个类似Xcode的TabBar控件) ARC已启用 现在,交易如下: NSMutableArray* sidebarItems = [@[ [DMTabBarItem tabBarItemWithIcon:[NSImage templateImageNamed:@"One" withSize:iconSize] tag:0 tooltip:@"Files"], [DMTabBarItem

好的,现在我再次面对发送给解除分配实例的可怕的
消息

  • 我正在使用(基本上是一个类似Xcode的TabBar控件)
  • ARC已启用
现在,交易如下:

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;
} 
@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;
  • 控件附带的示例运行良好
  • 我已经启用了僵尸(甚至尝试使用仪器进行调试,不过——老实说——我不知道该找什么)
  • deallocated
    实例是TabBar的
    tabBarItems
    数组(承载不同按钮的数组)
这是我添加项目的方式:

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;
} 
@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;
这是不同元素的声明方式:

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;
} 
@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;
这是
DMTabBar
的界面(最“重要”的部分):

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;
} 
@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
,它们似乎就在那里(至少一开始是这样)。他们为什么被释放?(请记住,控制代码和项目代码都使用圆弧)


有什么想法吗?(如果您需要了解其他信息,请告诉我…

您是否尝试使用常用的内存调试技术运行,即

  • 带有僵尸的乐器,以及
  • 在Xcode的编辑方案>诊断>内存管理选项卡中设置各种标志

仅当assign不是对象、委托和IBoutlet时才使用

更改此项:

@property (nonatomic,assign) DMTabBarItem*      selectedTabBarItem;
为此:

@property (nonatomic,strong) DMTabBarItem*      selectedTabBarItem;

EWWWW,iVar IBOUTLES!这是什么,ObjC 1.0?@CodaFi最初它们被声明为属性,但我太绝望了,我一直在尝试每一种可能的组合……你可能有线程问题吗?UIKit和线程一点也不一致。@CodaFi感谢您关注这个问题。然而,我已经设法解决了这个问题(正如这类问题通常发生的那样,关于这个解决方案,我无法发布任何可以普遍理解的内容)。顺便说一句,这篇文章(如标签所示)不是关于Cocoa Touch和UIKit的,而是与OSX相关的。1)我不确定应该如何使用仪器,2)如前所述,我已经确定了要发布的特定对象。所以