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
// 'App' is ambiguous for type lookup in this context - Error and how to fix it: | |
import SwiftUI | |
import RealmSwift | |
// MARK: - Issue | |
@main | |
struct MyApp: App { // <- 'App' is ambiguous for type lookup in this context | |
init() { | |
// Configure Realm |
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 WatchConnectivity | |
class WatchSessionManager: NSObject, WCSessionDelegate { | |
static let sharedManager = WatchSessionManager() | |
private override init() { | |
super.init() | |
} | |
private let session: WCSession? = WCSession.isSupported() ? WCSession.default : 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
import AVFoundation | |
func getThumbnail(url: URL) -> UIImage? { | |
do { | |
let asset = AVURLAsset(url: url , options: nil) | |
let imgGenerator = AVAssetImageGenerator(asset: asset) | |
imgGenerator.appliesPreferredTrackTransform = true | |
let cgImage = try imgGenerator.copyCGImage(at: CMTimeMake(0, 1), actualTime: nil) | |
let thumbnail = UIImage(cgImage: cgImage) |
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 DegreesRadiansHelper { | |
static func deg2Rad(_ degrees: Double) -> Double { | |
return degrees * .pi / 180 | |
} | |
static func rad2Deg(_ radians: Double) -> Double { | |
return radians * 180.0 / .pi | |
} | |
} |
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 DelayHelper { | |
private var cancelled = false | |
static func run(delay: Double, closure: @escaping () -> ()) { | |
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { | |
if !self.cancelled { | |
closure() | |
} | |
} | |
} |
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 roundCorners(corners: UIRectCorner, radius: CGFloat) | |
{ | |
let size = CGSize(width: radius, height: radius) | |
let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: size) | |
let mask = CAShapeLayer() | |
mask.path = path.cgPath | |
self.layer.mask = mask | |
} |
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
// Layer extension for adding border on one of the sides | |
extension CALayer { | |
func addBorder(edge: UIRectEdge, color: UIColor, thickness: CGFloat) { | |
let border = CALayer() | |
switch edge { | |
case UIRectEdge.top: | |
border.frame = CGRect.init(x: 0, y: 0, width: frame.width, height: thickness) |
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
var arrays: [[String: AnyObject]] = [[String: AnyObject]]() | |
func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { | |
return true | |
} | |
func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { | |
let dic = self.arrays[sourceIndexPath.section] | |
if let array = dic["arrays"] as? NSMutableArray |