• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSPersistentDocument, Core Data & Cryptation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPersistentDocument, Core Data & Cryptation


  • Subject: Re: NSPersistentDocument, Core Data & Cryptation
  • From: Nicko van Someren <email@hidden>
  • Date: Fri, 17 Jun 2005 13:14:42 +0100

On 17 Jun 2005, at 11:54, Stefano Furiosi wrote:
this is my frist post here.

Welcome!

I have an NSDcoument based application (for now coded with cocoa & binding) that need to do the following 3 things:

1) Compress (zip) the file or data before save it.
2) Crypt the data before save it, and store a public key in the document data.
3) Save in the documet global information like window frame size, some flags, public key etc. etc.


I havn't found a way to do that with core data architecture right now. The questions are:

There is a way to hook the saved data and compress it in the core data flow? I use to do this in loadDataRepresentation and dataRepresentationOfType in my actual app.

The natural way to do this would be to build an encrypting "store type" for Core Data. Unfortunately as far as I know there is currently no way to provide different sorts of store type at the moment; the API is not published and the classes are private to the CoreData framework.


One would hope that you might be able to fake up a layer of compression and encryption using a new URL protocol. Annoyingly, even though you specify the location of your data store in URL form Apple do not actually fetch the data through the URL loading mechanism, even when using the binary or the XML store store type which load the entire file into memory when it is opened. If you try to pass in any sort of non-file URL you get:
*** Uncaught exception: <NSInvalidArgumentException> CoreData only supports file URLs.
While I can see why it would be necessary to impose such a limitation on SQLite stores it seems a rather unnecessary restriction on stores which load the whole file at once. Come on Apple; we live in a web connected world so why can't we read our data files over HTTP, FTP or something else we've not thought of yet?


There is a way to save single flags and other information not related to the other data in the documet? Considering the fact that this data need to be updated without raise an undo/redo, thigs that happen if I use a single ManagedObject.

Here you are better off. What you are asking for is file meta-data. For this you can use setMetadata:forPersistentStore: in the NSPersistentStoreCoordinator and there is some example code for this at:
http://developer.apple.com/documentation/Cocoa/Conceptual/ NSPersistentDocumentTutorial/07_Metadata/chapter_8_section_1.html


Anyone have some clue about this? I don't need an example code, just a way to follow.

As it stands I don't think that there is an easy way to handle your encrypted data problem. Your best bet is probably going to be to modify the dataRepresentationOfType implementation to write the document to a temporary file, read it back in, encrypt it and then spit it back out, possibly with the meta-data being added at this level. Then you can make loadDataRepresentation do the reverse. This has numerous drawbacks (the cleartext is written to disc, it doubles the memory usage etc.) but it will probably work.


    Cheers,
        Nicko

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSPersistentDocument, Core Data & Cryptation
      • From: mmalcolm crawford <email@hidden>
References: 
 >Programatically Set Data Cell Alignment (From: Austin Sarner <email@hidden>)
 >NSPersistentDocument, Core Data & Cryptation (From: Stefano Furiosi <email@hidden>)

  • Prev by Date: Hotkey in Cocoa (not using carbon).
  • Next by Date: Re: how do you change the highlight color for rows in an NSOutlineView?
  • Previous by thread: NSPersistentDocument, Core Data & Cryptation
  • Next by thread: Re: NSPersistentDocument, Core Data & Cryptation
  • Index(es):
    • Date
    • Thread