Swift Extensions Best Practices
<p>I've recently gotten addicted to <code>Extensions</code>. One thing I've found to be a gigantic PITA is figuring where I stashed a useful method for something like an <code>Array</code>, an <code>NSManagedObject</code>, etc.</p>

<p>What I've done is put my extensions in an <code>NSObject</code> class file called <code>CustomExtensions</code> and I list the Class Extensions there in alphabetical order.</p>

<p>It works, but I want to see if it aligns with best practices. If not, what is the best way to track <code>Extensions</code>?</p>

<p>Here's what I've done:</p>

<pre><code>class CustomExtensions: NSObject {
    /*
     Useful extensions, nothing else here
     */
}
// Example extension    
extension Int {
    func formatAsTimeString() -&gt; String {
        let seconds = self % 60
        let minutes = (self / 60) % 60
        let hours = self / 3600
        let stringHours = hours &gt; 9 ? String(hours) : "0" + String(hours)
        let stringMinutes = minutes &gt; 9 ? String(minutes) : "0" + String(minutes)
        let stringSeconds = seconds &gt; 9 ? String(seconds) : "0" + String(seconds)

        if hours &gt; 0 {
            return "\(stringHours):\(stringMinutes):\(stringSeconds)"
        }
        else {
            return "\(stringMinutes):\(stringSeconds)"
        }
    }
}
// More extensions below
</code></pre>