ReactiveCocoa / ReactiveObjC

The 2.x ReactiveCocoa Objective-C API: Streams of values over time
MIT License
2.6k stars 496 forks source link

RACSignal flattenMap always says Assertion failure in -[RACStream(Operations) flattenMap:]_block_invoke_2() #162

Closed smoothdvd closed 5 years ago

smoothdvd commented 5 years ago
[[[[threadDao
         threadsWithImage:forum]
         deliverOn:[RACScheduler scheduler]]
         flattenMap:^__kindof RACSignal * _Nullable(RACTuple *tuple) {
             NSArray *threads = tuple.first;
             return [RACSignal concat:[threads.rac_sequence map:^id(Thread *thread) {
                 return [threadDao messageOfThread:thread];
             }]];
         }]
         subscribeNext:^(NSDictionary *dict) {
             Thread *thread = [dict objectForKey:@"thread"];
             UIImage *image = [dict objectForKey:@"image"];
//             NSString *url = [dict objectForKey:@"url"];
             [self->_threads addObject:dict];
             IDMPhoto *photo = [IDMPhoto photoWithImage:image];
             photo.caption = thread.message.title;
             [self->_photos addObject:photo];

             [self performSelectorOnMainThread:@selector(loadMoreImgage) withObject:nil waitUntilDone:YES];
         } error:^(NSError *error) {
             NSLog(@"%@", error);
         } completed:^{
             self->_loading = NO;
             self.navigationItem.rightBarButtonItem.enabled = YES;
         }];
erikprice commented 5 years ago

Does [threadDao messageOfThread:thread] return a signal?

smoothdvd commented 5 years ago

@erikprice Yes. these code works

flattenMap:^__kindof RACSignal * _Nullable(RACTuple *tuple) {
             NSArray *threads = tuple.first;
             return [threadDao messageOfThread:[threads objectAtIndex:0]];
             //return [RACSignal concat:[threads.rac_sequence map:^id(Thread *thread) {
             //    return [threadDao messageOfThread:thread];
             //}]];
         }]
smoothdvd commented 5 years ago

Strange, those code will run in testflight and production mode without error report.

smoothdvd commented 5 years ago

Remove duplicated libraries from OTHER_LDFLAGS in Pods-app.debug.xcconfig solved this issue.