Exception: Define -[AFMultipartBodyStream setDelegate:]!' #2201

Closed
m1entus opened this Issue Jul 21, 2014 · 2 comments

Projects

None yet

3 participants

@m1entus
m1entus commented Jul 21, 2014

Hi,
I'm trying to make background upload task with couple photos,

NSMutableURLRequest *request = [self.backgroundManager.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:@"stories" relativeToURL:self.backgroundManager.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {

    [frames enumerateObjectsUsingBlock:^(NSURL *obj, NSUInteger idx, BOOL *stop) {

        [formData appendPartWithFormData:[[NSString stringWithFormat:@"%@",@(idx+1)] dataUsingEncoding:NSUTF8StringEncoding]
                                    name:[NSString stringWithFormat:@"test[images_attributes][%@][position]",@(idx)]];

        [formData appendPartWithFileURL:obj name:[NSString stringWithFormat:@"test[images_attributes][%@][image]",@(idx)] fileName:[NSString stringWithFormat:@"test_ios_%@.jpeg",@(idx)] mimeType:@"image/jpeg" error:nil];
    }];


} error:nil];

NSURLSessionUploadTask *task = [self.backgroundManager uploadTaskWithStreamedRequest:request progress:progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { ... }];

When resuming task i'm getting exception:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -setDelegate: only defined for abstract class. Define -[AFMultipartBodyStream setDelegate:]!'
*** First throw call stack:
(
0 CoreFoundation 0x03a79ca6 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x033e38bf objc_exception_throw + 44
2 CoreFoundation 0x03a79bcd +[NSException raise:format:] + 141
3 Foundation 0x01293e4e NSRequestConcreteImplementation + 219
4 Foundation 0x0129bfe2 -[NSStream(NSStream) setDelegate:] + 50
5 CFNetwork 0x05962055 -[__NSCFBackgroundDataTask captureStream:] + 371
6 CFNetwork 0x059622b6 __70-[__NSCFBackgroundDataTask _onqueue_needNewBodyStream:withCompletion:]_block_invoke_2 + 86
7 libdispatch.dylib 0x0418f84a _dispatch_call_block_and_release + 15
8 libdispatch.dylib 0x041ab3ff _dispatch_client_callout + 14
9 libdispatch.dylib 0x04194578 _dispatch_queue_drain + 1424
10 libdispatch.dylib 0x04193f90 _dispatch_queue_invoke + 142
11 libdispatch.dylib 0x04195e06 _dispatch_root_queue_drain + 312
12 libdispatch.dylib 0x04196e67 _dispatch_worker_thread2 + 45
13 libsystem_pthread.dylib 0x044fbdab _pthread_wqthread + 336
14 libsystem_pthread.dylib 0x044ffcce start_wqthread + 30
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Any ideas how to solve this?

@mattt
mattt commented Aug 12, 2014

Interesting. I haven't seen this in the wild, but I think I know what's going on here.

ca1441e adds the missing explicit @synthesize. I'll cut a new release soon, so try updating to that and let me know if that helps.

@mattt mattt closed this Aug 12, 2014
@nkanellopoulos

This also happens with streamStatus.
(with version 2.4.1 & Xcode 5.1.1)

'NSInvalidArgumentException', reason: '*** -streamStatus only defined for abstract class. Define -[AFMultipartBodyStream streamStatus]!'

This is STRANGE. Look at the code! The @synthesize exists!

@implementation AFMultipartBodyStream
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wimplicit-atomic-properties"
#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100)
@synthesize delegate;
#endif
@synthesize streamStatus;
@synthesize streamError;
#pragma clang diagnostic pop

Here is the full stack trace:
2014-09-15 14:49:04.404 Energent[11526:590b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -streamStatus only defined for abstract class. Define -[AFMultipartBodyStream streamStatus]!'
*** First throw call stack:
(
0 CoreFoundation 0x03d101e4 exceptionPreprocess + 180
1 libobjc.A.dylib 0x03a8f8e5 objc_exception_throw + 44
2 CoreFoundation 0x03d0ffbb +[NSException raise:format:] + 139
3 Foundation 0x01008b3b NSRequestConcreteImplementation + 218
4 Foundation 0x01010746 -[NSStream(NSStream) streamStatus] + 48
5 Energent 0x00446771 -[AFMultipartBodyStream open] + 49
6 CoreFoundation 0x03cd1c44 CFReadStreamOpen + 116
7 CFNetwork 0x00ab995d _ZN30CoreReadStreamFromCFReadStream16_streamImpl_OpenEP13CFStreamErrorPh + 53
8 CFNetwork 0x00b8bae6 _ZThn60_N30CoreReadStreamFromCFReadStream16_streamImpl_OpenEP13CFStreamErrorPh + 34
9 CFNetwork 0x00a97112 _ZN14CoreStreamBase21_streamInterface_OpenEv + 72
10 CFNetwork 0x00ab8c34 _ZN17HTTPNetConnection19prepareTransmissionEP17HTTPNetStreamInfoP17__CoreWriteStream + 1614
11 CFNetwork 0x00ab8063 _ZN17HTTPNetConnection19requestStateChangedEPvN13NetConnection5StateEP13CFStreamError + 415
12 CFNetwork 0x00ab81fd _ZN13NetConnection18scheduleNewRequestEP13_CFNetRequestS1_h + 293
13 CFNetwork 0x00ab7da4 _ZN13NetConnection7enqueueEPvh + 538
14 CFNetwork 0x00ab7b26 _ZN17HTTPNetStreamInfo16_streamImpl_OpenEP13CFStreamErrorPh + 104
15 CFNetwork 0x00b1c846 _ZThn60_N17HTTPNetStreamInfo16_streamImpl_OpenEP13CFStreamErrorPh + 34
16 CFNetwork 0x00a97112 _ZN14CoreStreamBase21_streamInterface_OpenEv + 72
17 CFNetwork 0x00ab7315 _ZN12HTTPProtocol10openStreamEv + 267
18 CFNetwork 0x00b2a98c _ZN12HTTPProtocol26useNetConnectionForRequestEP13NetConnectionP15__CFHTTPMessageh + 1550
19 CFNetwork 0x00ab65d8 _ZN24HTTPConnectionCacheEntry28dispatchConnectionToProtocolEP13NetConnectionP12HTTPProtocolP18HTTPRequestMessageh + 284
20 CFNetwork 0x00ab63b9 _ZN24HTTPConnectionCacheEntry34notifyNextProtocolOfOpenConnectionEP13NetConnectionh + 349
21 CFNetwork 0x00ab371d _ZN24HTTPConnectionCacheEntry25enqueueRequestForProtocolEP12HTTPProtocolP15__CFHTTPMessage + 637
22 CFNetwork 0x00ab30db _ZN19HTTPConnectionCache34_onqueue_enqueueRequestForProtocolEP12HTTPProtocolP15__CFHTTPMessage + 185
23 CFNetwork 0x00b30897 ___ZN19HTTPConnectionCache25enqueueRequestForProtocolEP12HTTPProtocolP15__CFHTTPMessage_block_invoke + 35
24 CoreFoundation 0x03cb1c69 CFArrayApplyFunction + 57
25 CFNetwork 0x00aae441 _ZN19RunloopBlockContext7performEv + 155
26 CFNetwork 0x00b903f4 _ZThn16_N19RunloopBlockContext24multiplexerClientPerformEv + 20
27 CFNetwork 0x00aae257 _ZN17MultiplexerSource7performEv + 299
28 CFNetwork 0x00aae06c _ZN17MultiplexerSource8_performEPv + 76
29 CoreFoundation 0x03c9977f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 15
30 CoreFoundation 0x03c9910b CFRunLoopDoSources0 + 235
31 CoreFoundation 0x03cb61ae __CFRunLoopRun + 910
32 CoreFoundation 0x03cb59d3 CFRunLoopRunSpecific + 467
33 CoreFoundation 0x03cb57eb CFRunLoopRunInMode + 123
34 Foundation 0x00f28ece +[NSURLConnection(Loader) _resourceLoadLoop:] + 381
35 Foundation 0x00f84a07 -[NSThread main] + 76
36 Foundation 0x00f84966 __NSThread__main
+ 1275
37 libsystem_pthread.dylib 0x044b25fb _pthread_body + 144
38 libsystem_pthread.dylib 0x044b2485 _pthread_struct_init + 0
39 libsystem_pthread.dylib 0x044b7cf2 thread_start + 34
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment