init(colorLiteralRed:,green:,blue:,alpha:) deprecated in Swift 4

init(colorLiteralRed:green:blue:alpha:) is intended to be used with Color Literals which are managed by development tools. Why don’t you use normal init(red:green:blue:alpha:)? let startingColorOfGradient = UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0).cgColor let endingColorOFGradient = UIColor(red: 251.0/255.0, green: 247.0/255.0, blue: 234.0/255.0, alpha: 1.0).cgColor let gradient: CAGradientLayer = CAGradientLayer() (Writing like 234.0/255.0 is not mandatory, in … Read more

iso8601 date json decoding using swift4 [duplicate]

You can use like this : enum DateError: String, Error { case invalidDate } let decoder = JSONDecoder() let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .iso8601) formatter.locale = Locale(identifier: “en_US_POSIX”) formatter.timeZone = TimeZone(secondsFromGMT: 0) decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in let container = try decoder.singleValueContainer() let dateStr = try container.decode(String.self) formatter.dateFormat = “yyyy-MM-dd’T’HH:mm:ss.SSSXXXXX” if … Read more

type A requires that type B be a class type swift 4

You can’t have a WeakReference<ServiceDelegate>. ServiceDelegate itself is not an AnyObject, it just requires that anything that conforms to it be an AnyObject. You would need to make SomeClass generic and use the generic type as the type for the WeakReference: class SomeClass<T: ServiceDelegate> { private var observers = [WeakReference<T>]() } If the generic on … Read more

Cannot convert value of type NSAttributedString.DocumentAttributeKey to .DocumentReadingOptionKey

You need to pass one of the available NSAttributedString DocumentType options: Hypertext Markup Language (HTML) document. static let html: NSAttributedString.DocumentType Plain text document. static let plain: NSAttributedString.DocumentType Rich text format document. static let rtf: NSAttributedString.DocumentType Rich text format with attachments document. static let rtfd: NSAttributedString.DocumentType In this case you will need to pass the first … Read more

How to fix “Read-Write-Data Sandbox: error when using Mac Catalyst

MasterChief96, you are not alone. Here is my setup: MacOS 10.15.3 Xcode 11.4.1 I create a brand new SwiftUI “Hello World” project, enable Mac as a target device, a.k.a. Catalyst. I set the iOS deployment target to 13.2 (otherwise I get a MacOS runtime error saying I need Catalina 10.15.4) Set the scheme to “My … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)