Re: NSMutableDictionary -> NSData
Re: NSMutableDictionary -> NSData
- Subject: Re: NSMutableDictionary -> NSData
- From: email@hidden
- Date: Tue, 25 Jun 2002 06:27:31 -0500
Well, that begs a good question Brain! :-)
The ONLY reason I am doing all this work is because the application is a
"Doc App" that has as a document
type a "folder" which itself contains multiple files.. (4+ per
"document") 3 of these files I want in simple "plist"
format (the 4th and others are actually another sub-dir w/ more plist
files in it of another doc type)..
Given this architecture I sort of thought the only route to go w/ Cocoa
is a NSFileWrapper thing
creating a directory wrapper of the other files I want..
However, I am not so sure this is the best approach by a long shot given
what I have read about
the doc's wanting to create "temp copies" upon a "save" operation ..
There could easily be over 1000
files under the "doc" and I sure don't want to copy them back and forth
anytime there is a save if just
one changed.. Hmm..
So I am sort of rethinking that MAYBE the best bet is to override the
"folder" doc's writeToFile: ofType:
method and just handle the "folder" manually using a combo of
NSFileManager and the various writeToFile:s
Any thoughts/suggestions are most certainly welcome..
-Steve
On Monday, June 24, 2002, at 09:27 PM, Brian Webster wrote:
On Monday, June 24, 2002, at 08:25 PM, cocoa-dev-
email@hidden wrote:
So... How can I use NSFileWrapper to store the file easily in "plist"
format
if the information is in a dictionary??
If you want an XML property list in an NSData object, you can use the
Core Foundation function CFPropertyListCreateXMLData().
NSDictionary *myDictionary;
NSData* plistData;
plistData = (NSData*)CFPropertyListCreateXMLData(NULL,
(CFPropertyListRef)myDictionary);
For writing this data to a file, NSFileWrapper isn't really necessary.
Like you said, you can send a writeToFile:atomically: message to the
dictionary, or you could also send the same message to the NSData
object with the same results. If you wanted to write it via
NSFileWrapper, you could create one using initRegularFileWithContents:
and then write it to a file, but it wouldn't really gain you anything.
Is there a particular reason you want to use NSFileWrapper, or was it
just the first thing to pop out at you?
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.