You need something like that:
for (NSString *oneStoryData in yourArray) //yourArray is your array of stories
{
StoryData *storyDataEntity=[StoryData MR_createInContext:localContext];
storyDataEntity.stories= oneStoryData;
storyDataEntity.categoryType=categoryType;
storyDataEntity.timeStamp=[NSDate date];
}
[localContext MR_saveToPersistentStoreWithCompletion:^(BOOL success,NSError *error)
{
if (success) {
}
if (error) {
NSLog(@"error:%@",[error localizedDescription]);
}
}
}];
Also remember that StoryData is not an NSObject, it is a NSManagedObject.
From Apple documentation:
NSManagedObject is a generic class that implements all the basic behavior required of a Core Data model object. It is not possible to use instances of direct subclasses of NSObject (or any other class not inheriting from NSManagedObject) with a managed object context. You may create custom subclasses of NSManagedObject, although this is not always required. If no custom logic is needed, a complete object graph can be formed with NSManagedObject instances.
What is the object inside your NSArray? A NSString or what?
If your array have StoryData entities, then this is your problem, how are you creating these entities? With [[StoryData alloc]init] ?
Then inside the for you can do something like:
for (StoryData *oneStoryData in yourArray) //yourArray is your array of stories
{
StoryData *storyDataEntity=[StoryData MR_createInContext:localContext];
storyDataEntity.property1 = oneStoryData.property1;
storyDataEntity.property2 = oneStoryData.property2;
}
EDIT
Check this tutorial if you really want to save a whole NSArray/NSMutableArray in Core Data: