Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7188

How to handle NaN (Not a number) in Swift correctly?

$
0
0

I have a function that calculates the width of the cells for me based on a CollectionView. This layout is dynamic. In the simulator I repeated the case that the width / height of the CollectionView is NaN. How can I catch this value?

unfortunately the following solution does not work:

var collectionViewWidth = collectionView.frame.size.widthguard !widthCollectionView.isNaN, !widthCollectionView.isInfinite else {  return 250}collectionViewWidth -= collectionView.safeAreaInsets.left + collectionView.safeAreaInsets.right

Why isn't the case caught? guard should be able to catch the value, or not?


Viewing all articles
Browse latest Browse all 7188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>