magicalrecord

Error creating a separate NSManagedObjectContext

走远了吗. 提交于 2019-12-02 03:22:50
Before getting into my issue, please have a look at this image. Here is the actual data model: I retrieve a set of Records from a web API, create objects out of them, save them in core data and display them in the Today view. By default these records are returned for the current date. The user can tap on Past button to go to a separate view where he can choose a past or future date from a date picker view and view Records for that selected date. This means I have to call the API again passing the selected date, retrieve the data and save that data in core data and display them. When the user

Setting one-to-many relationship Core Data and Magical Record

妖精的绣舞 提交于 2019-12-02 01:04:33
If I have a Conversation entity with a one-to-many relationship to Messages (i.e. one conversation can have many messages) and I create a new message entity like so: _message = [Message MR_createInContext:_managedObjectContext]; _message set properties ... // Use this method to set relationship? [_conversation addToMessageObject:(Message *)] If I already have a _conversation object, how do I add this new message to the conversation (in other words, how do I establish the relationship)? I've had a problem with this too, you need to create the relationship on the _message instead: _message

MagicalRecord date parsing

若如初见. 提交于 2019-12-01 19:36:56
I've got a date in the following format: 2013-05-04T05:07:09+00:00 I'm using MagicalRecord to map the NSDate automatically. As far as I can see the above date format should comply with MagicalRecord's default date format: yyyy-MM-dd'T'HH:mm:ss'Z' . I have tried with a custom dateFormat entry in the attribute's user info (see this article ): yyyy-MM-ddTHH:mm:ss+Z , yyyy-MM-dd T HH:mm:ss Z , yyyy-MM-dd'T'HH:mm:ss'+'Z but none of them work in order to have it parse the date properly and it always returns nil regardless of setting a custom dateFormat or using MagicalRecord's default format. Let's

MagicalRecord date parsing

回眸只為那壹抹淺笑 提交于 2019-12-01 18:58:35
问题 I've got a date in the following format: 2013-05-04T05:07:09+00:00 I'm using MagicalRecord to map the NSDate automatically. As far as I can see the above date format should comply with MagicalRecord's default date format: yyyy-MM-dd'T'HH:mm:ss'Z' . I have tried with a custom dateFormat entry in the attribute's user info (see this article): yyyy-MM-ddTHH:mm:ss+Z , yyyy-MM-dd T HH:mm:ss Z , yyyy-MM-dd'T'HH:mm:ss'+'Z but none of them work in order to have it parse the date properly and it always

Passing a ManagedContext with Core Date + Magical Record

假装没事ソ 提交于 2019-12-01 09:42:00
问题 Currently I'm setting my NSManagedContext's by doing the following in ViewDidLoad: .h @property (nonatomic,strong) NSManagedObjectContext* managedObjectContext; .m viewDidLoad { _managedObjectContext = [NSManagedObjectContext MR_contextForCurrentThread]; } Question : Do I have to pass this same managed context to all of my subsequent viewcontrollers that I want to have access to this ManagedContexts, or can I write a new @property for each new viewcontroller's .h and then set each new

NSFetchedResultsController updating with wrong update type

∥☆過路亽.° 提交于 2019-12-01 07:44:09
问题 Please see the comments before blindly voting this as a duplicate. It isn't a duplicate question. First - I'm using MagicalRecord for core data. Second - My UICollectionView is populated with an NSFetchedResultsController . The NSPredicate for the NSFetchedResultsController is ... NSPredicate *eventPredicate = [NSPredicate predicateWithFormat:@"event = %@", self.event]; NSPredicate *deletedPredicate = [NSPredicate predicateWithFormat:@"deleted == NO"]; NSPredicate *compoundPredicate =

MagicalRecord importFromObject: JSON with dictionary?

狂风中的少年 提交于 2019-12-01 01:05:43
I'm parsing some JSON which comes to me in this format: { dataId = "823o7tr23d387g"; category = "link"; details = { text = "Some text associated with the link"; url = "http://www.url.com"; thumbnail_url = "http://www.url.com/picture.jpeg"; }; source = "CNN"; }, { ... }, MagicalRecord has a great importing method: + (id) importFromObject:(id)data; but does it support dictionaries inside the JSON dictionary so that it can automatically map the details {} to the appropriate properties? Is there a naming convention or something I will need to use? Check out this article about using MagicalRecord

MagicalRecord importFromObject: JSON with dictionary?

ε祈祈猫儿з 提交于 2019-11-30 19:12:00
问题 I'm parsing some JSON which comes to me in this format: { dataId = "823o7tr23d387g"; category = "link"; details = { text = "Some text associated with the link"; url = "http://www.url.com"; thumbnail_url = "http://www.url.com/picture.jpeg"; }; source = "CNN"; }, { ... }, MagicalRecord has a great importing method: + (id) importFromObject:(id)data; but does it support dictionaries inside the JSON dictionary so that it can automatically map the details {} to the appropriate properties? Is there

Magical Record import (next step)

◇◆丶佛笑我妖孽 提交于 2019-11-30 07:41:25
I've put next step in the title as this is not the same problem as my previous question with almost the exact same title. I have a Person entity. Person -------- name - mappedKeyName: FullName email - mappedKeyName: EmailAddress personID - mappedKeyName: Id -------- photos And a Photo entity. Photo -------- image createDate - mappedKeyName: Date photoID - mappedKeyName: Id -------- owner (type Person) - mappedKeyName: UserId - relatedByAttribute: personID There are other objects that relate to Person too and the JSON for these comes as so... { ObjectId : blah, Owner : { Id : 12345asdfg,

NSPredicate not executed

好久不见. 提交于 2019-11-30 07:18:25
This is quite funny. In my application I create thousands of entry in the database (in another thread, I'm using MagicalRecord). Everything seems working fine (from a background/foreground/context point of view). When, in the main thread, I try to fetch the "just inserted" data, I discovered the following behaviour: - (NSArray *) familiesInCompany:(Company *) company { NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"company == %@", company]; NSPredicate *predicate2 = [NSPredicate predicateWithFormat:@"company.name == %@", company.name]; NSArray *first = [Family MR_findAllSortedBy: