This works as expected:
// Return a sequence for photos
[[[[[[RACObserve(self, event.photos) filter:^BOOL(id value) { return value != nil ; }] flattenMap:^RACStream *(NSDictionary *photos)
{
NSLog(@"Got photos: %@" , photos) ;
return photos.rac_sequence.signal ;
}]
// Consider each photo
filter:^BOOL(NSDictionary *photoDescriptor)
{
NSLog(@"Descriptor: %@" , photoDescriptor) ;
return ((NSNumber *)photoDescriptor[@"primary"]).boolValue ;
}]
// Load the selected photo
map:^id(NSDictionary *selectedPhotoDescriptor)
{
NSLog(@"Photo URL: %@" , selectedPhotoDescriptor[@"url"]) ;
return [[AsyncImageFetcher imageAtURL:[NSURL URLWithString:selectedPhotoDescriptor[@"url"]] cache:YES] firstOrDefault:[UIImage imageNamed:@"detail_placeholder"]] ;
}]
// Deliver on main thread
deliverOn:RACScheduler.mainThreadScheduler]
subscribeNext:^(id x)
{
((UIImageView *)self.headerView).image = x ;
}] ;
This does not; the image is never set:
RAC( ((UIImageView *)self.headerView), image ) =
// Return a sequence for photos
[[[[[RACObserve(self, event.photos) filter:^BOOL(id value) { return value != nil ; }] flattenMap:^RACStream *(NSDictionary *photos)
{
NSLog(@"Got photos: %@" , photos) ;
return photos.rac_sequence.signal ;
}]
// Consider each photo
filter:^BOOL(NSDictionary *photoDescriptor)
{
NSLog(@"Descriptor: %@" , photoDescriptor) ;
return ((NSNumber *)photoDescriptor[@"primary"]).boolValue ;
}]
// Load the selected photo
map:^id(NSDictionary *selectedPhotoDescriptor)
{
NSLog(@"Photo URL: %@" , selectedPhotoDescriptor[@"url"]) ;
return [[AsyncImageFetcher imageAtURL:[NSURL URLWithString:selectedPhotoDescriptor[@"url"]] cache:YES] firstOrDefault:[UIImage imageNamed:@"detail_placeholder"]] ;
}]
// Deliver on main thread
deliverOn:RACScheduler.mainThreadScheduler] ;
Why?