Class: AppDelegate
- Inherits:
-
Object
- Object
- AppDelegate
- Defined in:
- lib/nitron/ui/extensions/app_delegate+storyboard.rb,
lib/nitron/data/extensions/app_delegate+core_data.rb
Instance Method Summary collapse
- #application(application, didFinishLaunchingWithOptions: launchOptions) ⇒ Object
- #managedObjectContext ⇒ Object
- #managedObjectModel ⇒ Object
- #persistentStoreCoordinator ⇒ Object
- #storyboard ⇒ Object
Instance Method Details
#application(application, didFinishLaunchingWithOptions: launchOptions) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/nitron/ui/extensions/app_delegate+storyboard.rb', line 2 def application(application, didFinishLaunchingWithOptions:launchOptions) @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) if storyboard @window.rootViewController = storyboard.instantiateInitialViewController end @window.rootViewController.wantsFullScreenLayout = true @window.makeKeyAndVisible true end |
#managedObjectContext ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nitron/data/extensions/app_delegate+core_data.rb', line 2 def managedObjectContext @managedObjectContext ||= begin applicationName = NSBundle.mainBundle.infoDictionary.objectForKey("CFBundleName") documentsDirectory = NSFileManager.defaultManager.URLsForDirectory(NSDocumentDirectory, inDomains:NSUserDomainMask).lastObject; storeURL = documentsDirectory.URLByAppendingPathComponent("#{applicationName}.sqlite") error_ptr = Pointer.new(:object) unless persistentStoreCoordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration:nil, URL:storeURL, options:nil, error:error_ptr) raise "Can't add persistent SQLite store: #{error_ptr[0].description}" end context = NSManagedObjectContext.alloc.init context.persistentStoreCoordinator = persistentStoreCoordinator context end end |
#managedObjectModel ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/nitron/data/extensions/app_delegate+core_data.rb', line 21 def managedObjectModel @managedObjectModel ||= begin model = NSManagedObjectModel.mergedModelFromBundles([NSBundle.mainBundle]).mutableCopy model.entities.each do |entity| begin Kernel.const_get(entity.name) entity.setManagedObjectClassName(entity.name) rescue NameError entity.setManagedObjectClassName("Model") end end model end end |
#persistentStoreCoordinator ⇒ Object
39 40 41 |
# File 'lib/nitron/data/extensions/app_delegate+core_data.rb', line 39 def persistentStoreCoordinator @coordinator ||= NSPersistentStoreCoordinator.alloc.initWithManagedObjectModel(managedObjectModel) end |
#storyboard ⇒ Object
15 16 17 |
# File 'lib/nitron/ui/extensions/app_delegate+storyboard.rb', line 15 def storyboard @storyboard ||= UIStoryboard.storyboardWithName("MainStoryboard", bundle:nil) end |