How do I make NSData from cabron-Handle
How do I make NSData from cabron-Handle
- Subject: How do I make NSData from cabron-Handle
- From: Gore <email@hidden>
- Date: Sat, 26 Jan 2002 16:27:46 +0200
I would like to encode my Handle variable so that I can save me SndBank
on the HD...
my code looks like this (SndBank is the class this code is in...):
///////////////////////////////// interface
@interface SndBank : NSObject
{
Handle sndHandle;
}
//////////////////////////////// implementation
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeValueOfObjCType: @encode(Handle) at: &sndHandle];
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
[aDecoder decodeValueOfObjCType: @encode(Handle) at: &sndHandle];
return self;
}
+ (SndBank *)sndWithData:(NSData *)data
{
return [[NSUnarchiver unarchiveObjectWithData: data] autorelease];
}
- (NSData *)sndData
{
return [NSArchiver archivedDataWithRootObject: self];
}
/////////////////////////////////////////////////////////////
the sndHandle is the handle returned from my sound recording methood...
if there is a way to record sound using apples cocoa frameworks, then
please tell me!