strange warnings for transformable attribute
I was using transformable attributes and everything work fine instead of those warnings:
15.10.11 22:14:07,191 cdtool: CoreData: warning: no NSValueTransformer with class name 'ArrayToDataTransformer' was found for attribute 'directions' on entity 'DatabaseConnections'
15.10.11 22:14:07,191 cdtool: CoreData: warning: no NSValueT开发者_如何学JAVAransformer with class name 'ArrayToDataTransformer' was found for attribute 'updateChoices' on entity 'DatabaseConnections'
15.10.11 22:14:07,193 cdtool: CoreData: warning: no NSValueTransformer with class name 'ArrayToDataTransformer' was found for attribute 'testingResult' on entity 'DestinationsListWeBuy'
may anybody tell how to move out this warning. for sure, everything is correct, attribute is optional, transformable. bellow is a class implementation:
#import <Foundation/Foundation.h>
@interface ArrayToDataTransformer : NSValueTransformer {
}
@end
#import "ArrayToDataTransformer.h"
@implementation ArrayToDataTransformer
+ (BOOL)allowsReverseTransformation {
return YES;
}
+ (Class)transformedValueClass {
return [NSData class];
}
- (id)transformedValue:(id)value {
//Take an NSArray archive to NSData
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:value];
return data;
}
- (id)reverseTransformedValue:(id)value {
//Take NSData unarchive to NSArray
NSArray *array = (NSArray*)[NSKeyedUnarchiver unarchiveObjectWithData:value];
return array;
}
@end
Before you can call a custom transformer you have to register it with:
+[NSValueTransformer setValueTransformer:forName:]
… otherwise, the runtime doesn't know the transformer exist.
精彩评论