MusicKit  0.0.0
MKFileWriter Class Reference

A MKFileWriter is an MKInstrument that realizes MKNotes by writing them to a file on the disk. An abstract class, MKFileWriter provides common functionality for the MusicKit subclasses such as MKScorefileWriter (currently the only subclass of MKFileWriter). More...

#include <MKFileWriter.h>


Detailed Description

A MKFileWriter is an MKInstrument that realizes MKNotes by writing them to a file on the disk. An abstract class, MKFileWriter provides common functionality for the MusicKit subclasses such as MKScorefileWriter (currently the only subclass of MKFileWriter).

A MKFileWriter is associated with a file on disk or a data object, either by the file's name or through an NSMutableData object. If you associate a MKFileWriter with a file name (through the setFile: method) the object opens and closes the file for you: The file is opened for writing when the object first receives the realizeNote: message and closed after the performance. A MKFileWriter remembers its file name between performances, but the file is overwritten each time it's opened.

The setStream: method sets the FileWriter's stream instance variable to the given NSMutableData object. Creating and saving the NSMutableData object is the responsibility of the application. After each performance, stream is set to nil.

The subclass responsibility realizeNote:fromNoteReceiver:, inherited from MKInstrument, is passed on to the MKFileWriter subclasses. Two other methods, initializeFile and finishFile, can be redefined in a subclass, although neither must be. initializeFile is invoked just before the first MKNote is written to the file and should perform any special initialization such as writing a file header. finishFile is invoked after each performance and should perform any post-performance cleanup. The values returned by initializeFile and finishFile are ignored.


The documentation for this class was generated from the following file: