I got the solution.
I have two NSObjects, one that saves all my artists, and one per each artist. So in the NSObject where I save the artist information, I had a BOOL value where I stored the value if I selected the artist as favourite. I hadn't added this BOOL value to his NSCoding protocols methods, because the BOOL isn't a object, and I couldn't, so I have created a NSNumber to store the value of the Favorite on it, and after I added it to the NSCoding protocols methods, is working good.
Code in my Artist NSObject.
.h
@interface SBQArtistModel : NSObject <NSCoding>
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSString *bio;
@property (strong, nonatomic) NSString *location;
@property (strong, nonatomic) NSString *linkSoundcloud;
@property (strong, nonatomic) NSString *linkFacebook;
@property (strong, nonatomic) NSString *thumbnail;
@property (strong, nonatomic) NSString *image;
@property (strong, nonatomic) NSNumber *numberFavorite;
@property (nonatomic) BOOL Favorite;
.m
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeObject:self.name forKey:@"name"];
[encoder encodeObject:self.bio forKey:@"bio"];
[encoder encodeObject:self.location forKey:@"location"];
[encoder encodeObject:self.linkSoundcloud forKey:@"linkSoundcloud"];
[encoder encodeObject:self.linkFacebook forKey:@"linkFacebook"];
[encoder encodeObject:self.thumbnail forKey:@"thumbnail"];
[encoder encodeObject:self.image forKey:@"image"];
[encoder encodeObject:self.numberFavorite forKey:@"numberFavorite"];
}
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
if( self != nil )
{
self.name = [decoder decodeObjectForKey:@"name"];
self.bio = [decoder decodeObjectForKey:@"bio"];
self.location = [decoder decodeObjectForKey:@"location"];
self.linkSoundcloud = [decoder decodeObjectForKey:@"linkSoundcloud"];
self.linkFacebook = [decoder decodeObjectForKey:@"linkFacebook"];
self.thumbnail = [decoder decodeObjectForKey:@"thumbnail"];
self.image = [decoder decodeObjectForKey:@"image"];
self.numberFavorite = [decoder decodeObjectForKey:@"numberFavorite"];
}
return self;
}
Thanks, and I hope have explained well ;)