These rules are adopted from the AngularJS commit conventions.
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
@interface MySingleton : NSObject | |
// ... | |
+ (instancetype) sharedInstance; | |
+ (instancetype) alloc __attribute__((unavailable("alloc not available, call sharedInstance instead"))); | |
- (instancetype) init __attribute__((unavailable("init not available, call sharedInstance instead"))); | |
+ (instancetype) new __attribute__((unavailable("new not available, call sharedInstance instead"))); |
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
disabled_rules: | |
- variable_name | |
- colon | |
- comma | |
- control_statement | |
excluded: | |
- Carthage | |
- Pods | |
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
[UIColor colorWithHexString:@"#f5e6a1"]; |
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
extension ViewController: UITableViewDataSource, UITableViewDelegate { | |
// As long as `total` is the last case in our TableSection enum, | |
// this method will always be dynamically correct no mater how many table sections we add or remove. | |
func numberOfSections(in tableView: UITableView) -> Int { | |
return TableSection.total.rawValue | |
} | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
// Using Swift's optional lookup we first check if there is a valid section of table. |
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
import Foundation | |
import PlaygroundSupport | |
/// A thread-safe array. | |
public class SynchronizedArray<Element> { | |
fileprivate let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent) | |
fileprivate var array = [Element]() | |
} | |
// MARK: - Properties |
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
struct MediaItem { | |
var duration: Int? | |
var title: String? | |
var urlString: String? | |
static func parseM3U(contentsOfFile: String) -> [MediaItem]? { | |
var mediaItems = [MediaItem]() | |
contentsOfFile.enumerateLines({ line, stop in | |
if line.hasPrefix("#EXTINF:") { | |
let infoLine = line.stringByReplacingOccurrencesOfString("#EXTINF:", withString: "") |
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
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | |
let text = collections[indexPath.row].name | |
let width = UILabel.textWidth(font: titleFont, text: text) | |
return CGSize(width: width + left + right, height: height) | |
} |
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
1. Очень крутая книжка по сетям (стек OSI) – Charles Severance “Introduction to Network: How the Internet works” | |
2. URLCache – https://nshipster.com/nsurlcache/ | |
3. Ресёрч HTTP-кеширования с использованием URLCache https://qnoid.com/2016/04/10/A-primer-in-HTTP-caching-and-its-native-support-by-iOS.html | |
4. Анализ доступности сети: | |
* SimplePing – https://developer.apple.com/library/archive/samplecode/SimplePing/Introduction/Intro.html | |
* https://github.com/dustturtle/RealReachability | |
* https://github.com/ankitthakur/SwiftPing | |
* https://github.com/lmirosevic/GBPing | |
* https://github.com/rwbutler/Connectivity | |
* Баг с 2009 года – https://lists.apple.com/archives/macnetworkprog/2009/May/msg00056.html |
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
//: Playground - noun: a place where people can play | |
protocol ObjectMapper { | |
associatedtype SourceType | |
associatedtype ResultType | |
func map(_ object: SourceType) -> ResultType |
OlderNewer