Added support for tracking upload progress

This commit is contained in:
Blake Watters
2010-10-26 14:05:29 -04:00
parent f02e48f252
commit 0127df862d
4 changed files with 16 additions and 3 deletions

View File

@@ -18,7 +18,7 @@
// TODO: The managedObjectContext should be settable at the class level to ease coupling with
// singleton object manager
+ (NSManagedObjectContext*)managedObjectContext {
return [[[RKObjectManager globalManager] objectStore] managedObjectContext];
return [[[RKObjectManager sharedManager] objectStore] managedObjectContext];
}
+ (NSEntityDescription*)entity {

View File

@@ -177,4 +177,9 @@ typedef enum RKRequestMethod {
*/
- (void)requestDidCancelLoad:(RKRequest*)request;
/**
* Sent when a request has uploaded data to the remote site
*/
- (void)request:(RKRequest*)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
@end

View File

@@ -102,8 +102,10 @@
}
}
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
NSLog(@"Connection dedSendBodyData invoked. %d bytesWritten, %d totalBytesWritten, %d totalBytesExpectedToWrite", bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
if ([[_request delegate] respondsToSelector:@selector(request:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)]) {
[[_request delegate] request:_request didSendBodyData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
}
}

View File

@@ -268,4 +268,10 @@
}
}
- (void)request:(RKRequest*)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
if ([_delegate respondsToSelector:@selector(request:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)]) {
[(NSObject<RKRequestDelegate>*)_delegate request:request didSendBodyData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
}
}
@end