This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for family in UIFont.familyNames.sorted() { | |
let names = UIFont.fontNames(forFamilyName: family) | |
print("Family: \(family) Font names: \(names)") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AVAsset | |
let asset: AVAsset(URL: NSURL(string: "...")) | |
let assetSizeBytes = asset.tracksWithMediaType(AVMediaTypeVideo).first?.totalSampleDataLength | |
// File | |
let fileOnDiskSizeBytes = try! NSFileManager.defaultManager().attributesOfItemAtPath("...")[NSFileSize] as! NSNumber |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Copyable { | |
init(copy:Self) | |
} | |
extension Copyable { | |
func copy() -> Self { | |
return Self.init(copy: self) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let numbers: [Any] = [Int(3), Double(4.0), Int(7)] | |
for number in numbers { | |
switch number { | |
case is Int: | |
print("Integer") | |
case is Double: | |
print("Double") | |
default: break | |
} | |
} |