This line
[selectedCategories setByAddingObject:category];
creates a new set that is not assigned to any variable. Try using a mutable set
NSMutableSet *selectedCategories = [NSMutableSet set];
for (NSString *categoryName in self.categories /*NSMutableArray propterty*/) {
Category *category = [NSEntityDescription
insertNewObjectForEntityForName:@"Category" inManagedObjectContext:context];
category.name = categoryName;
[selectedCategories addObject:category];
}