core-data

Found empty data in sqlite when send via MFMailcomposeController

会有一股神秘感。 提交于 2020-01-06 04:34:05
问题 I am sending SQLite(Coredata sqlite file) file via email but found empty data in all tables in the received mail. I am using below code: MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; mc.mailComposeDelegate = self; [mc setSubject:subject]; [mc setMessageBody:body isHTML:FALSE]; if (attachmentData) { [mc addAttachmentData:attachmentData mimeType:fileMimeType fileName:fileName]; } if (!recipients || recipients.count == 0) { recipients = @[]; } [mc setToRecipients

Core Data breaking many-to-many relationship

扶醉桌前 提交于 2020-01-06 04:17:16
问题 I have the following data model and i want to break the many-to-many relationship between EntityA and EntityB. I'm doing this by removing EntityC object that connects both of them. I found that EntityA still have a relationship with EntityB although I saved the managed object context, I can see the changes take affect after EntityA records are re-fetched from database. Is there something I'm missing? Thanks in advance,Sarah 回答1: I agree with the comment from Barry, from your description it

CoreData predicate ANY + AND with to-many relationship

。_饼干妹妹 提交于 2020-01-06 04:07:10
问题 I have those entities defined in my model: [Sample] - results (to many relation with [Result]) [Parameter] - results (to many relation with [Result]) - compliant (number value) [Result] - parameter (relation with [Parameter]) - sample (relation with [Sample]) For a [Sample] object "MySample", I need to get all [Parameter] objects that have: [Result].compliant = 1 AND [Result].sample = MySample So, I'm trying to fetch [Parameter] objects using predicate that will be a sum of those predicates:

Core Data - Fetch all objects NOT in a relationship

空扰寡人 提交于 2020-01-06 03:45:08
问题 I have a core data entity A that has a one-to-many relationship with entity B. Given a set of instances of entity B, how do I retrieve all instances of A that are NOT in a relationship with those instances of B? (I'm talking about IOS core data, if that matters). 回答1: NSSet *bEntities = a.b; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF NOT IN %@", bEntities]; NSManagedObjectContext *moc = ...; NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init] autorelease];

Xcode Swift application deployed to iphone losses CoreData after iPhone reboot

一笑奈何 提交于 2020-01-06 02:55:44
问题 My simple Swift application uses an SQLite DB in CoreData for table view data. I deployed the app to my iPhone via the simulator. After a reboot of the iPhone the persistent data was no longer present....but the application launches. What must I do to keep the data persistent? IOS9.2.1 & Swift 2.0 回答1: One thing that's interesting about CoreData is that it isn't a database. It's a wrapper around a data store, in your case SQLite. If you don't tell CoreData to save it's contents, it will never

iOS: Two Entities - Fetch, Merge, and Sort

会有一股神秘感。 提交于 2020-01-06 02:26:27
问题 I need to perform a fetch from two different entities, merge them, and then sort them based on a field that both entities have: 'lastModifiedDate'. lastModifiedDate is NSDate NSFetchRequest *fetchRequest1 = [[NSFetchRequest alloc] init]; NSFetchRequest *fetchRequest2 = [[NSFetchRequest alloc] init]; NSEntityDescription *entity1 = [NSEntityDescription entityForName:@"Entity1" inManagedObjectContext:self.managedObjectContext]; [fetchRequest1 setEntity:entity1]; NSEntityDescription *entity2 =

core data in storage array attribute or work with files or relationship entities

与世无争的帅哥 提交于 2020-01-06 02:19:28
问题 I'm trying to work for a long time with the core data. And I read a lot of tutorials about this and i asked a lot of questions. Finally I started to work on core data Through this guide: www.appcoda.com/introduction-to-core-data/ And now I'm stuck! I want to create the kind of attribute, array. And was told me it's a not a good way to store array about attribute. These work with a relationship. But the problem here. If you look at the guide, it does not create files (classes) entities And all

no hit on if-statement

旧城冷巷雨未停 提交于 2020-01-05 19:05:41
问题 I am trying to get a hit on my if-statement. I fetch qDiff (integer32) from the Core Data db and everything works except get a hit on the if-statements: NSString *diff; NSArray *fetchedObjects = [qContext executeFetchRequest:fetchRequest error:&error]; for (NSManagedObject *info in fetchedObjects) { NSLog(@"idQ: %@", [info valueForKey:@"idQ"]); NSLog(@"qDiff: %@", [info valueForKey:@"qDiff"]); //<<<<<<<<<Print correct number diff = [info valueForKey:@"qDiff"]; NSLog(@"diff: %@", diff); //<<<<

Managed object not deleted properly in my core database

一曲冷凌霜 提交于 2020-01-05 18:04:19
问题 I am trying to delete some objects from my Entity Reservation . I am doing it like this. NSManagedObjectContext *context = reservation.managedObjectContext; [context deleteObject:reservation]; NSError *error = nil; if (![context save:&error]) { NSLog(@"Error is %@",error); } After that I delete my object I fetch the whole entity again. I can see that the object is delete from my entity . But when I restart my app, all my objects that I deleted in the previous session are back stored in my

How to pass object between several views in storyboard, iOS Dev

二次信任 提交于 2020-01-05 15:22:13
问题 I have searched for this but the answer is too simple to satisfy me :( I want to pass a NSManagedObjectContext from TabBarController to almost every view controllers in my app. In detail, my storyboard structure is kind of like this: TabBarController >>> several tab items views ( this is easy to pass, just pass one time in according view controllers). But I have another relation: TabBarController (the one mentioned above) >>> NavigationController >>> TableViewControllerOne >>>