Re: NSData
Re: NSData
- Subject: Re: NSData
- From: Ed Baskerville <email@hidden>
- Date: Sun, 20 Feb 2005 17:06:00 -0800
It *sounds* like you want to serialize/archive objects so that you can
save them into a file (or something along those lines).
In short; you're probably going to want to use NSArchiver or
NSKeyedArchiver (both of which inherit from NSCoder) to add objects to
an archive. NSArchiver requires that you serialize and deserialize
objects in the same order; NSKeyedArchiver lets you assign objects in
the archive to specific keys, and retrieve them in any order using
those keys.
But you should start by reading the Archives and Serializations topic
in the Cocoa documentation to get a feel conceptually for how this all
works:
http://developer.apple.com/documentation/cocoa/Conceptual/Archiving/
index.html
This covers how to create an archive of objects that implement the
NSCoder protocol (including NSNumber and NSString) as well as how to
implement archiving methods for custom classes.
If you're developing a document-based application, you'll want to check
out the Document-Based Applications topic, specifically the "Creating a
Subclass of NSDocument" section, which explains how data archiving fits
into the document-based application architecture:
http://developer.apple.com/documentation/cocoa/Conceptual/Documents/
index.html
In general, you'll want to get into the habit of checking the "topics"
documentation before trying something new. Especially for fundamental
tasks such as archiving & serialization, there will often be a Cocoa
way of doing things, a set of concepts you need to understand before
doing things the Cocoa way. The API reference is just a list of methods
and what they do--useful if you already understand the system at a
conceptual level, but not a good starting point.
If you still need help after consulting the documentation, can you
provide more details of exactly what you're trying to do, so we can
provide better advice?
--Ed
On Feb 20, 2005, at 4:42 PM, Michael S. Swan wrote:
hello all,
I am trying to figure out how to add objects such as NSNumber, or
NSString to an NSData or NSMutableData. The documentation is rather
lacking. I found dataWithBytes: but I don't know if it will take an
object or not, it seems as though there would be a dataWithObjects:
method somewhere, perhaps even a appendDataWithObject: for
NSMutabelData. After all NSArray, NSDictionary, and the like all have
methods to add objects. I am sure this is a silly question and is due
to my newbieness but any help would be apperciated.
thanks,
mike
_______________________________________________
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
_______________________________________________
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
References: | |
| >NSData (From: "Michael S. Swan" <email@hidden>) |