Closed backwardm closed 4 years ago
No problem about the issue. If you want to ask it on the forum, be sure to tag me, @sxross in the post.
In answer to your question, the data files are created by using NSCoding::encodeWithCoder
, and then persisted to the device. So the file is not guaranteed to be textual. A better way to handle it is on initialization in AppDelegate
, do something like this:
# ProMotion used here.
class AppDelegate < PM::Delegate
status_bar true, animation: :fade
def on_load(app, options)
seed if Pet.count == 0
open PetScreen.new(nav_bar: true)
# open HomeScreen.new(nav_bar: true)
end
def seed
fluffy = Pet.create(name: 'Fluffy', species: 'Cat', breed: 'Heinz 57')
rover = Pet.create(name: 'Rover', species: 'Dog', breed: 'Boxer')
basil = Pet.create(name: 'Basil', species: 'Cat', breed: 'Persian')
fluffy.foods << Food.create('smelly cat food')
fluffy.save
end
end
Sorry for making this an 'issue'. I'm not sure how to ask this question otherwise.
I am learning RubyMotion by creating a simple application. I'd like the application will include a pre-populated offline database and show the data in a simple table view. When you show the deserialize_from_file(file.dat) method in the examples, is it possible to create that .dat file beforehand that is pre-populated and include it with the application? If so, what could you use to create / manage that file?
Thanks for your help, and sorry again for making this an 'issue'.