【轉】iphone 輸入/輸出流異步讀寫數據
分類: iphone2012-05-30 14:50 2484人閱讀
一、首先是往文件裏寫入數據app
WriteFile.hiphone
- #import <Foundation/Foundation.h>
- #import <UIKit/UIKit.h>
- @class NoteDb;
- @interface WriteFile : NSObject<NSStreamDelegate>{
-
- NSString *parentDirectoryPath;
-
- NSOutputStream *asyncOutputStream;
-
- NSData *outputData;
-
- NSRange outputRange;
-
- NoteDb *aNoteDb;
- }
- @property (nonatomic,retain) NSData *outputData;
- @property (nonatomic,retain) NoteDb *aNoteDb;
- -(void)write;
- @end
實現文件WriteFile.m
二、其次是從文件裏讀出數據
ReadFile.h異步
- #import <Foundation/Foundation.h>
- @class NoteDb;
- @interface ReadFile : NSObject<NSStreamDelegate>{
-
- NSString *parentDirectoryPath;
-
- NSInputStream *asyncInputStream;
-
- NSMutableData *resultData;
-
- NoteDb *aNoteDb;
- }
- @property(nonatomic,retain)NoteDb *aNoteDb;
- @property (nonatomic, retain) NSMutableData *resultData;
- -(void)read;
- - (void)appendData:(NSData*)_data;
- - (void)dataAtNoteDB;
- - (NoteDb*)getNoteDb;
- @end
實現文件ReadFile.m
歡迎關注本站公眾號,獲取更多信息