Permalink
Browse files

Some changes. Don't remember what though.

Probably not very important then.
  • Loading branch information...
mysteriouspants committed Dec 28, 2011
1 parent 54f7ee4 commit d987091bdef2343e10d13717cb7b373a2c31a2fc
Showing with 8 additions and 17 deletions.
  1. +1 −1 FSURLOperation.h
  2. +7 −16 FSURLOperation.m
View
@@ -16,6 +16,7 @@
@property (strong) NSError * error;
@property (strong) NSThread* targetThread; // changing this after the request has started produces undefined behavior.
@property (copy) void(^onFinish)(NSHTTPURLResponse* resp, NSData* payload, NSError* error);
+// todo: delegate based callbacks
+ (FSURLOperation*)URLOperationWithRequest:(NSURLRequest*)req
completionBlock:(void(^)(NSHTTPURLResponse* resp, NSData* payload, NSError* error))completion;
@@ -24,6 +25,5 @@
onThread:(NSThread*)thread;
- (id)initWithRequest:(NSURLRequest*)_request;
-- (void)startOnThread:(NSThread*)thread; // completely ignore targetThread and just run this on whatever the heck thread I say, dangit!
@end
View
@@ -17,9 +17,9 @@
@interface FSURLOperation ()
@property (readwrite, assign) enum FSURLOperationState state;
-@property (readwrite, retain) NSURLConnection* connection;
-@property (readwrite, retain) NSSet* runLoopModes;
-@property (readwrite, retain) NSMutableData* dataAccumulator;
+@property (strong) NSURLConnection* connection;
+@property (strong) NSSet* runLoopModes;
+@property (strong) NSMutableData* dataAccumulator;
+ (NSThread*)networkRequestThread;
- (void)finish;
@@ -32,13 +32,13 @@ @implementation FSURLOperation
@synthesize response;
@synthesize payload;
@synthesize error;
+@synthesize targetThread;
+@synthesize onFinish;
@synthesize state;
@synthesize connection;
@synthesize runLoopModes;
@synthesize dataAccumulator;
-@synthesize targetThread;
-@synthesize onFinish;
+ (FSURLOperation*)URLOperationWithRequest:(NSURLRequest*)req
completionBlock:(void(^)(NSHTTPURLResponse* resp, NSData* payload, NSError* error))completion
@@ -100,7 +100,8 @@ - (void)finish
{
[self willChangeValueForKey:@"isFinished"];
self.state = finished;
- self.onFinish(self.response, self.payload, self.error);
+ if (self.onFinish) self.onFinish(self.response, self.payload, self.error);
+ // TODO: Delegate-based callbacks
[self didChangeValueForKey:@"isFinished"];
}
@@ -121,16 +122,6 @@ - (void)operationDidStart
[self.connection start];
}
-- (void)startOnThread:(NSThread*)thread
-{
- if (![self isReady])
- return;
-
- self.state = executing;
-
- [self performSelector:@selector(operationDidStart) onThread:thread withObject:nil waitUntilDone:YES modes:[self.runLoopModes allObjects]];
-}
-
#pragma mark NSOperation
- (void)start

0 comments on commit d987091

Please sign in to comment.