我有一个简单NSValueTransformer
的应该将逗号分隔的字符串first, second, third
转换为数组的方法。所以在我的 CoreData 模式中,我有options
我设置Transformed
并指定我的 Transformer 的属性。
这是我的变压器:
-(id)transformedValue:(id)value{
// convert it to an array
if(!value){
return nil;
} else{
NSString *languages = value;
NSArray *result = [languages componentsSeparatedByString: @", "];
// return result;
return @"test Result";
}
}
现在,当我返回变量时,result
我收到以下错误(length
看起来像是期待一个NSString
):
... 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x6cc59a0'
如果我返回上面的测试字符串,则会收到此错误(bytes
看起来它需要一个NSData
对象):
... 'NSInvalidArgumentException', reason: '-[__NSCFConstantString bytes]: unrecognized selector sent to instance 0xf0780'
看起来有一个我似乎没有掌握的概念问题。也很奇怪+(Class)transformedValueClass
,+(BOOL)allowsReverseTransformation
在使用调试器时永远不会“触动”。