UA-17470720-3

Jump to content


Photo
- - - - -

STV 3.0 and MagicalRecords. Objects are not beeing persisted

core-data

  • Please log in to reply
4 replies to this topic

#1 mgcds

mgcds

    Jr. Member

  • STV Lite
  • PipPip
  • 10 posts
Reputation: 1
Good

Posted 27 January 2015 - 04:52 AM

Hello Forum,

 

my app uses STV 3.0 and core data through the MagicalRecord 2.2 framework.

i´m having trouble with the persistent storage of entities created by STV. When I create the objects "by hand" (without STV) and store them into the MR defaultContext the objects are persisted. I pass STV the MR defaultContext and the entities are created and as i can see also contained in this context, but they are not persistently stored. I also tried removing MR from the app and it obviously worked, the created objects were persisted.

I assume STV is storing in a background thread and thats where it gets too advanced for me.
Can somebody bring some light into this?

 

Thank you very much

 

Max

i create my scentitydefinition like this:

 

 SCEntityDefinition *taskStepDef = [SCEntityDefinition definitionWithEntityName:@"TaskStepEntity"
                            managedObjectContext:  [NSManagedObjectContext defaultContext]  //This returns the context managed by MagicalRecords
                             propertyNamesString:@"name;details"];

 



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 29 January 2015 - 10:36 AM

Hi Max,

 

I am guessing that you're testing on the simulator and not pressing the Home button before quitting the app.

 

By default, STV follows Apple's recommendation by depending on the AppDelegate's 'applicationWillTerminate' and 'applicationDidEnterBackgroundmethods to persist the context. By quitting the simulator before pressing the Home button (shift+cmd+H), neither of these methods get the chance to be called. Testing on the device, you should not face any of these problems of course.

 

Hope this helps.


  • David DelMonte likes this

#3 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 29 January 2015 - 02:21 PM

 Testing on the device, you should not face any of these problems of course.

 

technically even when running on a device starting the app using xcode, if you still press the stop button in xcode the data does not persist. You still need to tap the home button on the device just like the sim to save the data:)


  • David DelMonte likes this

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#4 mgcds

mgcds

    Jr. Member

  • STV Lite
  • PipPip
  • 10 posts
Reputation: 1
Good

Posted 11 February 2015 - 08:34 AM

Thank you both for your answers and sry for my delay.

 

My problem was and still is the handling of the managedobjectContext by magicalRecord. After building a nasty workaround for it everything related to STV worked fine again.

 

Thank you and cheers

Max



#5 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 11 February 2015 - 08:40 AM

Thanks for the update Max, glad everything finally worked out.







Also tagged with one or more of these keywords: core-data

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users