私はIBActionを備えたクラス(ダイスコントローラー)を持っていました、そしてそれはいくつかのIBOutletsをトリガーするでしょう、すべてが幸せでした。それ以来、コードを整理してIBActionを別のクラス(playercommand)に配置するためのより良い方法を見つけました。playercommanは、すべてのIBOutletsを備えたdicecontrollerのメソッドを呼び出します。ただし、現在、どのアウトレットも何も表示していません。アウトレットをxibに再接続し、新しいアウトレットを作成しましたが、どの形式のIBOutletsも機能していないようです。ただし、NSLogは正常に機能し、渡した配列は正常に受信されています。
最近、Xcodeの動作がおかしくなり、クラッシュする問題が発生しました。これは、Xcodeを再インストールすることで修正されました。これは別の問題かもしれないと考えて、もう一度やりましたが、愛はありません。これは私が知らないIBのニュアンスだと思います
私はまた、これを調べる方法を本当に知りません。何時間も何かを見つけようとしていました。助けは励みになるでしょう。
PlayerCommand.h
#import "DiceRoll.h"
#import "diceController.h"
@interface playerCommand : NSObject
- (IBAction)roll:(NSButton *)sender;
@end
Playercommand.m
#import "playerCommand.h"
@implementation playerCommand
- (IBAction)roll:(NSButton *)sender {
DiceRoll *currentTurn = [[DiceRoll alloc] init];
[currentTurn rolldice];
diceController *currentFields = [[diceController alloc] init];
[currentFields updatetockNameField:[currentTurn diceValuesArray]];
}
@end
dicecontroller.h
@interface diceController : NSObject
-(void)updatetockNameField: (NSArray*) diceValues;
@end
dicecontroller.m
#import "diceController.h"
// declaring private properties
@interface diceController()
@property (weak) IBOutlet NSTextField *ActionField;
@property (weak) IBOutlet NSTextField *QuantityField;
@end
@implementation diceController
-(void)updatetockNameField:(NSArray *) diceValues {
switch ([[diceValues objectAtIndex:2] integerValue]) {
case 0 ... 1:
[[self ActionField] setStringValue:@"Up"];
break;
case 2 ... 3:
[[self ActionField] setStringValue:@"Down"];
break;
case 4 ... 5:
[[self ActionField] setStringValue:@"Div"];
break;
default:
[[self ActionField] setStringValue:@"Err"];
break;
}
switch ([[diceValues objectAtIndex:2] integerValue]) {
case 0 ... 1:
[[self QuantityField] setIntegerValue:5];
break;
case 2 ... 3:
[[self QuantityField] setIntegerValue:10];
break;
case 4 ... 5:
[[self QuantityField] setIntegerValue:20];
break;
default:
[[self QuantityField] setStringValue:@"E"];
break;
}
} //end of updatetockNameField method
@end