英文:
NSToolbar customization not available
问题
According to the documentation, this property has been available since macOS 10.4.
I'm on High Sierra 10.13 and getting an error:
../src/osx/cocoa/toolbar.mm:465:15: warning: instance method '-allowsUserCustomization:' not found (return type defaults to 'id')
[-Wobjc-method-access]
[self allowsUserCustomization:YES];
^~~~~~~~~~~~~~~~~~~~~~~
../src/osx/cocoa/toolbar.mm:339:12: note: receiver is an instance of the class declared here
@interface wxNSToolbar : NSToolbar
^
../src/osx/cocoa/toolbar.mm:466:15: warning: instance method '-autosaveConfiguration:' not found (return type defaults to 'id')
[-Wobjc-method-access]
[self autosaveConfiguration:YES];
^~~~~~~~~~~~~~~~~~~~~
../src/osx/cocoa/toolbar.mm:339:12: note: receiver is an instance of the class declared here
@interface wxNSToolbar : NSToolbar
^
Could someone please explain what is going on?
TIA!!
[EDIT]
I made the following implementation:
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
{
auto array = [NSArray arrayWithObjects:&m_default[0] count:m_default.size()];;
return [NSArray arrayWithObjects:&m_default[0] count:m_default.size()];;
}
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
{
auto array = [NSArray arrayWithObjects:&m_allowed[0] count:m_allowed.size()];;
return [NSArray arrayWithObjects:&m_allowed[0] count:m_allowed.size()];;
}
However, after executing the line auto array = ...
, the program crashes.
The variables m_allowed and m_default are of the type std::vector.
The vectors do have elements in them. Running under lldb, I can see their content.
What am I doing wrong?
英文:
ALL,
According to the documentation the property is available since macOS 10.4.
I'm on High Sierra 10.13 and getting an error:
../src/osx/cocoa/toolbar.mm:465:15: warning: instance method '-allowsUserCustomization:' not found (return type defaults to 'id')
[-Wobjc-method-access]
[self allowsUserCustomization:YES];
^~~~~~~~~~~~~~~~~~~~~~~
../src/osx/cocoa/toolbar.mm:339:12: note: receiver is instance of class declared here
@interface wxNSToolbar : NSToolbar
^
../src/osx/cocoa/toolbar.mm:466:15: warning: instance method '-autosaveConfiguration:' not found (return type defaults to 'id')
[-Wobjc-method-access]
[self autosaveConfiguration:YES];
^~~~~~~~~~~~~~~~~~~~~
../src/osx/cocoa/toolbar.mm:339:12: note: receiver is instance of class declared here
@interface wxNSToolbar : NSToolbar
^
Could someone please explain what is going on?
TIA!!
[EDIT]
I made a following implementation:
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
{
auto array = [NSArray arrayWithObjects:&m_default[0] count:m_default.size()];;
return [NSArray arrayWithObjects:&m_default[0] count:m_default.size()];;
}
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
{
auto array = [NSArray arrayWithObjects:&m_allowed[0] count:m_allowed.size()];;
return [NSArray arrayWithObjects:&m_allowed[0] count:m_allowed.size()];;
}
However, after executing the line auto array = ...
, program crashes.
The variables m_allowed and m_default are of the type std::vector.
The vectors do have elements in them. Running under lldb I can see their content.
What am I doing wrong?
答案1
得分: 0
设置一个属性在Objective-C中:
self.allowsUserCustomization = YES;
使用setter方法:
[self setAllowsUserCustomization:YES];
英文:
Setting a property in Objective-C:
self.allowsUserCustomization = YES;
Using the setter method:
[self setAllowsUserCustomization:YES];
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论