カスタム NSFormatter を使用して、NSTokenField 内の文字列の長さを判断したいと考えています。
私は NSFormatter を実装し、それを xib 内に接続しました。これで、NSTokenField に接続されたフォーマッタ インプレースでアプリケーションを実行すると、次のエラーが発生します。
2011-12-31 18:15:11.761 MyApp[4706:a0f] -[NSCFArray length]: unrecognized selector sent to instance 0xf4a530
(gdb) describe 0xf4a530
Undefined command: "describe". Try "help".
(gdb) p 0xf4a530
$1 = 16033072
(gdb) po 0xf4a530
<NSCFArray 0xf4a530>(
{
Format = "%01d";
FormatIndex = 0;
Name = "$Counter$";
},
{
Format = "";
Name = hey;
}
)
評価されるテキストセルには実際にアイテムの配列が含まれていることを理解したので、おそらくこれらを文字列に変換する必要がありますが、コードでエラーが発生している場所は次のとおりです。
//Set this so that user can't enter a super long amount and overflow the character array lower in the engine.
[fieldFormatter setMaximumLength:40];
私は fieldFormatter オブジェクトを評価し、int のメンバー変数を 40 に設定しています...実際にはまだテキストを評価するべきではありません...そうですか?