iSightを使ってBooklog,MediaMarkerインポート用CSVファイルを生成するアプリ
修订版 | 8e4982704f04d53b31a7064de7e5d9e7b5a62ba6 (tree) |
---|---|
时间 | 2011-03-04 23:30:31 |
作者 | masakih <masakih@user...> |
Commiter | masakih |
[Mod] ファイルエンコードをサブクラスで変更可能にした。
@@ -30,5 +30,6 @@ NSString *tagsString(NSArray *tags); | ||
30 | 30 | - (void)buildLines; // send lineForBook: message for each books if needed. you can override for anothor building way. |
31 | 31 | - (NSString *)lineForBook:(BEBookInformation *)book; |
32 | 32 | - (NSString *)lineSeparator; // default line sparator is CRLF. |
33 | +- (NSStringEncoding)fileEncoding; // default fileEncoding is NSShiftJISStringEncoding. | |
33 | 34 | |
34 | 35 | @end |
@@ -45,14 +45,6 @@ | ||
45 | 45 | [books release]; |
46 | 46 | [super dealloc]; |
47 | 47 | } |
48 | -- (void)buildLines | |
49 | -{ | |
50 | - for(BEBookInformation *book in books) { | |
51 | - if(book.exported) continue; | |
52 | - NSString *line = [self lineForBook:book]; | |
53 | - if(line) [lines addObject:line]; | |
54 | - } | |
55 | -} | |
56 | 48 | - (BOOL)exportToURL:(NSURL *)url |
57 | 49 | { |
58 | 50 | lines = [[NSMutableArray alloc] init]; |
@@ -63,7 +55,7 @@ | ||
63 | 55 | [lines release]; lines = nil; |
64 | 56 | NSError *error = nil; |
65 | 57 | BOOL isOK = NO; |
66 | - isOK = [string writeToURL:url atomically:YES encoding:NSShiftJISStringEncoding error:&error]; | |
58 | + isOK = [string writeToURL:url atomically:YES encoding:[self fileEncoding] error:&error]; | |
67 | 59 | if(!isOK) { |
68 | 60 | NSString *errorString = nil; |
69 | 61 | if(error) { |
@@ -90,7 +82,16 @@ NSString *tagsString(NSArray *tags) | ||
90 | 82 | } |
91 | 83 | |
92 | 84 | // for subclass |
85 | +- (void)buildLines | |
86 | +{ | |
87 | + for(BEBookInformation *book in books) { | |
88 | + if(book.exported) continue; | |
89 | + NSString *line = [self lineForBook:book]; | |
90 | + if(line) [lines addObject:line]; | |
91 | + } | |
92 | +} | |
93 | 93 | - (NSString *)lineForBook:(BEBookInformation *)book { return nil; } |
94 | 94 | - (NSString *)lineSeparator { return @"\r\n"; } |
95 | +- (NSStringEncoding)fileEncoding { return NSShiftJISStringEncoding; } | |
95 | 96 | |
96 | 97 | @end |