Permalink
Browse files

Updated project to save managed object context after parsing each post.

  • Loading branch information...
1 parent ecfea0b commit e2a9b0a81e4819bc4237f036a8e66be85f4560dc Jim Dovey committed Mar 22, 2011
@@ -72,7 +72,7 @@ typedef NSInteger AQGzipCompressionLevel;
// need to be subclasses of different parents
// My way around this is for each thing to *contain* a common instance, which stores
// all the common state information, etc.
-@interface AQGzipInputStream : NSInputStream <AQGzipMemoryStreamOptimisation>
+@interface AQGzipInputStream : NSInputStream <AQGzipMemoryStreamOptimisation, NSStreamDelegate>
{
NSInputStream * _compressedDataStream;
_AQGzipStreamInternal * _internal;
@@ -85,7 +85,7 @@ typedef NSInteger AQGzipCompressionLevel;
@end
-@interface AQGzipOutputStream : NSOutputStream <AQGzipMemoryStreamOptimisation, AQGzipOutputCompressor>
+@interface AQGzipOutputStream : NSOutputStream <AQGzipMemoryStreamOptimisation, AQGzipOutputCompressor, NSStreamDelegate>
{
NSOutputStream * _outputStream;
_AQGzipStreamInternal * _internal;
@@ -118,6 +118,8 @@ - (void) startTumblelogWithAttributes: (NSDictionary *) attrs
[self.tumblog setValue: [attrs objectForKey: @"name"] forKey: @"name"];
[self.tumblog setValue: [attrs objectForKey: @"title"] forKey: @"title"];
[self.tumblog setValue: [attrs objectForKey: @"timezone"] forKey: @"timezone"];
+
+ [self.managedObjectContext save: NULL];
}
- (void) startPostWithAttributes: (NSDictionary *) attrs
@@ -155,6 +157,12 @@ - (void) startPostWithAttributes: (NSDictionary *) attrs
}
}
+- (void) endPost
+{
+ NSAssert(self.currentPost != nil, @"End post tag found without a valid start tag");
+ [self.managedObjectContext save: NULL];
+}
+
- (void) endTag
{
NSAssert(self.currentPost != nil, @"No post encountered by parser");
Oops, something went wrong.

0 comments on commit e2a9b0a

Please sign in to comment.