DELAY() Expected expression in Xcode 9.0

I got expected expression error on DELAY(0.5) when running with xcode9.0.

It can run and no error in old xcode 8.


dispatch_after(DELAY(0.5),dispatch_get_main_queue(),^(void){

[_collectionView scrollToItemAtIndexPath:selectedIndexPath atScrollPosition:UICollectionViewScrollPositionRight animated:true];});


Thanks a lot for any ideas / suggestions / etc.

Replies

The first parameter to dispatch_after should be of type "dispatch_time_t" and DELAY(x) isn't anything meaningful in that context. Do you have a link to some documentation that suggests that it should work?

This is what you're looking for


dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
      
    [_collectionView scrollToItemAtIndexPath:selectedIndexPath atScrollPosition:UICollectionViewScrollPositionRight animated:true];}   
      
});

Hi QuinecyMorris,


Thanks for your reply and suggestion .

Actually the application is already on app store with that code.

Now I am checking that it can work or not in iOS 11. I got error in xcode 9.

Hi iTen,


Thanks for your reply.