Я это исправил, вот решение:
Мой объект - «Адрес» (примечание: это не NSArray)
Address.h
@interface Address : NSObject <NSSecureCoding>
@property (nonatomic, strong) NSString *street;
@property (nonatomic, strong) NSString *city;
@end
Address.m
@implementation Address
- (id) initWithCoder:(NSCoder *)aDecoder
{
self = [self init];
if (self == nil)
{
return nil;
}
self.street = [aDecoder decodeObjectOfClass:[Address class] forKey:@"street"];
self.city = [aDecoder decodeObjectOfClass:[Address class]
forKey:@"city"];
return self;
}
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeObject:self.street forKey:@"street"];
[encoder encodeObject:self.city forKey:@"city"];
}
+ (BOOL)supportsSecureCoding
{
return YES;
}
Archive.h
@property (nonatomic, strong) Address *address;
Archive.m
UserDBO *userDBO = [[UserDBO alloc] init];
// Архив
NSError *error = nil;
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.address requiringSecureCoding:YES error:&error];
if(error)
{
NSLog(@"archivedDataWithRootObject: %@", error);
}
userDBO.address = data;
// UnArchive
Address *address = [NSKeyedUnarchiver unarchivedObjectOfClass:[Address class] fromData:userDBO.address error:&error];
if(error)
{
NSLog(@"unarchivedObjectOfClass: %@", error);
}
UserDBO.h
@property (nonatomic, strong) NSData *address;