あれとこれのコンバータ
Revisión | a847337977809a42ffde6d8163ca254314ff88fa (tree) |
---|---|
Tiempo | 2011-12-03 01:02:59 |
Autor | masakih <masakih@user...> |
Commiter | masakih |
お気に入りコンバート
@@ -16,6 +16,7 @@ | ||
16 | 16 | |
17 | 17 | #import "BSBoardInformationObject.h" |
18 | 18 | #import "BSThreadInformationObject.h" |
19 | +#import "BSFavoriteObject.h" | |
19 | 20 | |
20 | 21 | |
21 | 22 | @implementation BSDCAppDelegate |
@@ -87,6 +88,17 @@ | ||
87 | 88 | query = [[SQLiteReservedQuery alloc] initWithQuery:sql usingSQLiteDB:[[DatabaseManager defaultManager] databaseForCurrentThread]]; |
88 | 89 | return query; |
89 | 90 | } |
91 | +- (SQLiteReservedQuery *)sqlForInsertFav | |
92 | +{ | |
93 | + static SQLiteReservedQuery *query = nil; | |
94 | + if(query) return query; | |
95 | + | |
96 | + NSString *sql = [NSString stringWithFormat:@"INSERT INTO %@ (%@, %@) VALUES (?, ?);", | |
97 | + FavoritesTableName, | |
98 | + BoardIDColumn, ThreadIDColumn]; | |
99 | + query = [[SQLiteReservedQuery alloc] initWithQuery:sql usingSQLiteDB:[[DatabaseManager defaultManager] databaseForCurrentThread]]; | |
100 | + return query; | |
101 | +} | |
90 | 102 | - (void)convertBoards:(NSArray *)boards |
91 | 103 | { |
92 | 104 | DatabaseManager *dm = [DatabaseManager defaultManager]; |
@@ -197,8 +209,19 @@ | ||
197 | 209 | [pool release]; |
198 | 210 | [self updateTime]; |
199 | 211 | |
212 | + pool = [[NSAutoreleasePool alloc] init]; | |
200 | 213 | panel.message = @"Converting Favorites ..."; |
201 | 214 | // Fav |
215 | + DatabaseManager *dm = [DatabaseManager defaultManager]; | |
216 | + NSArray *favs = [cdm fetchDataForEntityName:@"Favorite" | |
217 | + predicate:nil]; | |
218 | + for(BSFavoriteObject *fav in favs) { | |
219 | +// NSLog(@"%@", fav.thread.board.boardName); | |
220 | + NSUInteger boardID = [dm boardIDForURLString:fav.thread.board.boardURL]; | |
221 | + SQLiteReservedQuery *query = [self sqlForInsertFav]; | |
222 | + [query cursorWithFormat:F_Int F_NSNumberOfInt, | |
223 | + boardID, fav.thread.threadID]; | |
224 | + } | |
202 | 225 | |
203 | 226 | finish: |
204 | 227 | [pool release]; |