This part isn't right:
- (id)pasteboardPropertyListForType:(NSString *)type {
return [NSKeyedArchiver archivedDataWithRootObject:[MyClass class]];
}
It looks like you're trying to archive the actual MyClass
class, where you should actually be archiving the MyClass
object, i.e. a specific instance of MyClass
rather than the class itself. Also, you should probably be checking the type that's passed in to make sure that you're offering the data for the right thing. So, it should look something like:
- (id)pasteboardPropertyListForType:(NSString *)type {
if ([type isEqualToString:kUTTypeXML]) {
return [NSKeyedArchiver archivedDataWithRootObject:self.someInstanceOfMyClass];
}
return nil;
}
Finally, make sure that MyClass
implements the NSCoding
protocol so that you can create an archive containing the object's data.