gpt4 book ai didi

objective-c - 使用多个 nsarraycontroller 更改选定对象

转载 作者:行者123 更新时间:2023-12-03 17:11:19 26 4
gpt4 key购买 nike

我正在尝试实现如 developer.apple.com 所示的示例一切正常,但 selectedWeapon 没有改变。

Q1:我不知道我忘记了什么,所以选择可以正常工作问题 2:根据 Apple 的说法,“该示例不需要实际代码来设置用户界面”。我正在从代码填充对象。有什么方法可以将对象添加到 XIB 中的 arrayController 中吗?

@implementation Combatant

- (instancetype)initWithName:(NSString *)aName
{
self = [super init];
if (self) {
_weapons = @[@"Dagger", @"Sword", @"Pike"];
_name = aName;
_selectedWeapon = [_weapons firstObject];
}
return self;
}

@end

@interface Combatant : NSObject


@property (nonatomic, strong) NSString *name;
@property id selectedWeapon;
@property NSArray *weapons;

- (instancetype)initWithName:(NSString *)aName;

@end

存储库:https://github.com/xhruso00/moderatelyComplexBindings

enter image description here

enter image description here

enter image description here

最佳答案

Q1: NSPopupButton 的选择索引没有链接到 arrayController。没有它,arrayController 就不知道选择了哪个选项。Q2:不可能。 Apple 谈论粘合代码。

enter image description here

关于objective-c - 使用多个 nsarraycontroller 更改选定对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25628807/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com