passing user supplied info to persistent store

Discussion in 'Mac Programming' started by chrisbdaemon, Dec 30, 2008.

  1. chrisbdaemon macrumors newbie

    Joined:
    Jun 20, 2008
    #1
    Hey, I working on a core data app for managing passwords and I have a custom atomic store to handle the file encryption and decryption transparently, however my problem is that the user needs to be able to supply a password that is used to decrypt the store file when the application starts up and it seems that the persistent store gets loaded and processed before I have a chance to do that to do panel/sheet.

    I'm using bindings so I'm guessing that might be a factor in it with the persistent store coordinator being loaded automatically from the .xib file but I don't want to throw away bindings entirely just to do this.

    Anyone have any ideas how this can be done?
     
  2. MrFusion macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #2
    Try this:

    Override in your NSDocument class this function
    Code:
    - (void)makeWindowControllers {
    	//custom subclass of windowcontroller
    	MyWindowController *winControl = [[MyWindowController alloc] init];
    	[self addWindowController:winControl];//retain count +1
    	[winControl release];
    }
    
    This functions allows you to use your own NSWindowController, or in your case maybe use the standard windowscontroller.
    Instead of loading the window immediately, like I do, you could first do other stuff, such as present a panel that asks for a pasword.

    You can use bindings as well in this panel, but I am afraid you will have to play around with coredata functions to provide an NSManagedobject to the panel (or any of your NSWindowcontroller subclasses) and the like. Most of the bindings are still there, though, after some adjustments.

    Code:
    - (void)makeWindowControllers {
    
    //do what you have to do before loading the .xib file
    
    //custom subclass of windowcontroller
    	MyWindowController *winControl = [[MyWindowController alloc] init];
    	[self addWindowController:winControl];//retain count +1
    	[winControl release];
    }
    
     
  3. chrisbdaemon thread starter macrumors newbie

    Joined:
    Jun 20, 2008
    #3
    That sounds like it works but the only problem is, its not a document based application and I wasn't able to find anything similar in NSApplication (that and I don't know where else to look for it, lol)
     
  4. MrFusion macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #4
    I just came across this. Maybe it's helpful for you?

    In some situations, it is worthwhile to subclass NSDocumentController in non-NSDocument-based applications to get some of its features. For example, the NSDocumentController management of the Open Recent menu is useful in applications that don’t use subclasses of NSDocument.
     

Share This Page