Stack Exchange
coredata one to many relationship CoreDataGeneratedAccessors
I have a coredata project one to many. Here is my .h:
@class Categories, Tags;

@interface Content : NSManagedObject

@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSString * body;
@property (nonatomic, retain) Categories *category;
@property (nonatomic, retain) NSSet *tags;
@end

@interface Content (CoreDataGeneratedAccessors)

- (void)addTagsObject:(Tags *)value;
- (void)removeTagsObject:(Tags *)value;
- (void)addTags:(NSSet *)values;
- (void)removeTags:(NSSet *)values;

Here is my implementation:
    NSError *error = nil;

    // Categories:

    NSManagedObjectContext *moc = [self managedObjectContext];
    NSEntityDescription *contentDescription = [ NSEntityDescription entityForName:@"Categories" inManagedObjectContext:moc];

    NSFetchRequest *categoRequest = [NSFetchRequest new];
    categoRequest.entity = contentDescription;
    NSPredicate *categoPredicate = [NSPredicate predicateWithFormat:@"category like %@", _dropMenuOulet.stringValue];
    categoRequest.predicate = categoPredicate;

    NSArray *results = [moc executeFetchRequest:categoRequest error:&error];

    Categories *catego = (Categories*) [results objectAtIndex:0];

//    Tags:

    NSEntityDescription *tagsDescription = [ NSEntityDescription entityForName:@"Tags" inManagedObjectContext:moc];
    NSFetchRequest *tagsRequest = [NSFetchRequest new];
    tagsRequest.entity = tagsDescription;
    NSArray *tagsResults = [moc executeFetchRequest:tagsRequest error:&error];

    NSMutableArray *tagArray = [ NSMutableArray new];


    for (NSManagedObject *obj in tagsResults)
    {

        //firstName = [obj valueForKey:@"firstName"];
        Tags *storeTag = [obj valueForKey:@"tag"];
        [tagArray addObject:storeTag];
    }
    Content *content1 = [NSEntityDescription insertNewObjectForEntityForName:@"Content" inManagedObjectContext:moc];

    content1.category = catego;
    content1.title = _titleOutlet.stringValue;
    content1.body = _bodyOutlet.stringValue;

    NSMutableSet  *tagSet = [NSMutableSet set];

    for (int i = 0 ; i <tagArray.count; i++)
    {
        Tags *myTag = [tagArray objectAtIndex:i ];
        [tagSet addObject:myTag];

    }

    content1.tags = tagSet;

But on this line "content1.tags = tagSet;" I'm getting the following error:
[NSTaggedPointerString managedObjectContext]: unrecognized selector sent to instance 0x696669637355
NSTaggedPointerString managedObjectContext]: unrecognized selector sent to instance 0x696669637355

I'll really appreciate if you know what I'm doing wrong to get that error.

It looks like your NSMutableSet *tagSet contains objects (likely NSString instances) that are not Tags instances. 
On these lines:
Tags *storeTag = [obj valueForKey:@"tag"];
[tagArray addObject:storeTag];

You are adding the tag attribute rather than the Tags instance itself.
Maybe just replace those two lines with:
[tagArray addObject:obj];


Unrelated, but why do you create an array just to iterate through it a few lines later to build up your set? Once the code is working, you may want to optimize that a bit.

thank you this work great but if I want to contents of the tags per content I'm getting tags = "<relationship fault: 0x60000002d820 'tags'>"; . How can I access to the tags of the content?

I am not quite following your question. But in any case, I would suggest posting a new question rather than asking in comments. It will get much better visibility in the community.

I post a new question http://stackoverflow.com/questions/27574974/coredata-accessing-data-relationship-fault
