How to find PPI programmatically with precision
<p>I am trying to find out PPI(Pixels Per Inch) in iOS.</p>

<p>I couldn't find any direct way to query this like we do for display size</p>

<pre><code>UIScreen.mainScreen().bounds
</code></pre>

<p>There is a <a href="https://stackoverflow.com/a/7922666/730807">way to do it</a> by multiplying scale with standard generic PPI for iPhone(163) or iPad(132) but it's not accurate.</p>

<p>If the formula is right then <strong>PPI</strong> of <strong>iPhone 6 plus is 489</strong> but in reality the <strong>PPI is 401</strong> Here is the <a href="http://www.alphr.com/apple/apple-iphone-6/7076/iphone-6-vs-iphone-6-plus-screen-comparison" rel="nofollow noreferrer">reference</a> </p>

<p>For now it seems like hardcoding is the way to go.</p>

<p>But I'd like to do it programmatically using a formula.</p>