Hi all,
I have a STV Core Data app, RootEntity each with multiple ChildEntity, and each of the ChildEntity have multiple MediaEntity.
I'm able to export the MediaEntity file, and a plist with all the Core Data, er, data to a ZIP file.
I'm able to import the ZIP file, extract the MediaEntity file and place it in the correct place, and extract the plist and add the data back into Core Data. STV shows all the imported data as expected.
What I'm having problems with is automatically drilling down to the newly imported MediaEntity. If there are no other RootEntity it all works. If there is an existing RootEntity, wether it's the owner of the importing MediaEntity tor not, then I seem to get stuck in a orphan ChildEntity where selecting the cell just redisplays the same ChildEntity instead of the MediaEntity. Going back eventually crashes with a "Can't add self as a subView" error.
Here's the code to dispatch to the MediaEntity:
SCArrayOfObjectsSection *mediaItemsSection = (SCArrayOfObjectsSection *)[self.tableViewModel.activeDetailModel.activeDetailModel sectionAtIndex:1]; // The 2nd section has the MediaEntity MediaEntity *loopMediaItem; for (long i = 0; i < [mediaItemsSection.items count]; i++) { loopMediaItem = (MediaItemEntity *)[mediaItemsSection.items objectAtIndex:i]; if ([loopMediaItem.mediaItemGUID isEqualToString:mediaItemEntity.mediaItemGUID]) { NSLog(@"DISPATCH:%li",i); double delayInSeconds = 0.625; dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); dispatch_after(when, dispatch_get_main_queue(), ^(void){ [mediaItemsSection dispatchEventSelectRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:1]]; }); goto mediaItemDispatched; } loopMediaItem = nil; } NSLog(@"NOT DISPATCHED!"); mediaItemDispatched:
The delays are in there to allow STV time to create the activeDetailModel before I then call dispatchEventSelectRowAtIndexPath on that model.
As I say, it all works when there's no RootEntity to start with, but breaks otherwise.
Anyone else done anything similar? Any pointers? Comments?