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 sdevices = devices.flatMap({ (device: Device) -> String in | |
| return "\(device.brand)-\(device.hostname)-\(device.ipAddress)-\(device.macAddress)\n" | |
| }).flatMap({$0}).joined() | |
| DispatchQueue.main.async { | |
| JDAlert(title: "Found \(devices.count) Device(s).", message: sdevices, preferredStyle: .alert) | |
| .addAction(title: "OK", style: .default) { _ in } | |
| .show() | |
| } |
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
| //http://stackoverflow.com/questions/41940994/closure-cannot-implicitly-capture-a-mutating-self-paramter/41941810#41941810 | |
| private func capture(with block: @escaping () -> ()) { block() } |
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
| //#include <ifaddrs.h> in bridging-header first. | |
| fileprivate func getIPAddress() -> String? { | |
| var address : [String]? = [] | |
| // Get list of all interfaces on the local machine: | |
| var ifaddr : UnsafeMutablePointer<ifaddrs>? | |
| guard getifaddrs(&ifaddr) == 0 else { return nil} | |
| guard let firstAddr = ifaddr else { return nil} | |
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
| if #available(iOS 11.0, *) { | |
| let bottomPadding = view.safeAreaInsets.bottom | |
| } |
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
| ACTION = build | |
| AD_HOC_CODE_SIGNING_ALLOWED = NO | |
| ALTERNATE_GROUP = staff | |
| ALTERNATE_MODE = u+w,go-w,a+rX | |
| ALTERNATE_OWNER = grantdavis | |
| ALWAYS_SEARCH_USER_PATHS = NO | |
| ALWAYS_USE_SEPARATE_HEADERMAPS = YES | |
| APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer | |
| APPLE_INTERNAL_DIR = /AppleInternal | |
| APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation |
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
| // create results array | |
| __block NSMutableArray* results = [NSMutableArray new]; | |
| // create serial queue | |
| dispatch_queue_t queue = dispatch_queue_create("myQueue", 0); | |
| for(NSInteger i = 0; i < 10; i++) { | |
| // enqueue operation in queue | |
| dispatch_async(queue, ^{ | |
| // create semaphore |
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
| enum DateError: String, Error { | |
| case invalidDate | |
| } | |
| struct Spaceship : Codable { | |
| var name: String | |
| var createdAt: Date | |
| } | |
| let decoder = JSONDecoder() |
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
| class AlignTopCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
| var sectionLayout: HomeSectionLayout? | |
| override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { | |
| let attrs = super.layoutAttributesForElements(in: rect) | |
| var attrsCopy = [UICollectionViewLayoutAttributes]() | |
| let layout = sectionLayout ?? .PERSONAL | |
| for element in attrs! { |
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
| //validate tpo cell in visible cells, | |
| guard let tableView = self.superview as? UITableView, let ip = self.indexPath, tableView.indexPathsForVisibleRows?.contains(ip) == true else { | |
| return | |
| } |
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 scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { | |
| guard self.topSectionViewTopConstraint.constant > 0 else { return } | |
| let tableViewOffset = tableViewTopEdgeInset + scrollView.contentOffset.y | |
| let topSectionViewTop = tableViewTopEdgeInset - listHeaderView.dimViewHeight | |
| //-160 ~ 0 | |
| var offset = (topSectionViewTop - tableViewOffset) | |
| offset = offset > topSectionViewTop / 2.c ? -tableViewTopEdgeInset : -listHeaderView.dimViewHeight.c | |
| targetContentOffset.pointee.y = offset |
OlderNewer