swift5

RPBroadcastSampleHandler any method not getting called

丶灬走出姿态 提交于 2020-01-23 08:01:47
问题 I want to implement screen sharing functionality like skype(when app is in background then also it will share screen of iPhone), and for that i am using broadcast extension. Here its my code in my viewcontroller.swift import UIKit import ReplayKit @available(iOS 12.0, *) class ViewController: UIViewController { var broadcastPicker: RPSystemBroadcastPickerView? var broadcastSession : NSObject? override func viewDidLoad() { super.viewDidLoad() let kPickerFrame = CGRect(x: 100.0, y: 100.0, width

RPBroadcastSampleHandler any method not getting called

只谈情不闲聊 提交于 2020-01-23 08:00:26
问题 I want to implement screen sharing functionality like skype(when app is in background then also it will share screen of iPhone), and for that i am using broadcast extension. Here its my code in my viewcontroller.swift import UIKit import ReplayKit @available(iOS 12.0, *) class ViewController: UIViewController { var broadcastPicker: RPSystemBroadcastPickerView? var broadcastSession : NSObject? override func viewDidLoad() { super.viewDidLoad() let kPickerFrame = CGRect(x: 100.0, y: 100.0, width

How can I save an object of a custom class in Userdefaults in swift 5/ Xcode 10.2

梦想与她 提交于 2020-01-22 02:21:31
问题 I want to save the array patientList in UserDefaults. Patient is an custom class so I need to transfer it into Data object, but this doesn't work on Swift 5 like it did before. func addFirstPatient(){ let newPatient = Patient(name: nameField.text!, number: numberField.text!, resultArray: resultArray, diagnoseArray: diagnoseArray) let patientList: [Patient] = [newPatient] let encodeData: Data = NSKeyedArchiver.archivedData(withRootObject: patientList) UserDefaults.standard.set(encodeData,

How to reference video in custom data model for AVPlayer

守給你的承諾、 提交于 2020-01-16 17:06:28
问题 I've managed to reference images for my custom data model which is used to show unique cells their different information. I've been able to do it for images, as it's a lot easier, I just have no clue how to do it for videos. My data model looks like this: fileprivate let data = [ CustomData(title: "Test", image: #imageLiteral(resourceName: "ss-1"), url: "this-will-be-a-local-url-in-cache-to-a-video"), CustomData(title: "Test2", image: #imageLiteral(resourceName: "done-button"), url: "this

How to reference video in custom data model for AVPlayer

社会主义新天地 提交于 2020-01-16 17:03:20
问题 I've managed to reference images for my custom data model which is used to show unique cells their different information. I've been able to do it for images, as it's a lot easier, I just have no clue how to do it for videos. My data model looks like this: fileprivate let data = [ CustomData(title: "Test", image: #imageLiteral(resourceName: "ss-1"), url: "this-will-be-a-local-url-in-cache-to-a-video"), CustomData(title: "Test2", image: #imageLiteral(resourceName: "done-button"), url: "this

Render a CGImage (rather than UIImage) directly?

人走茶凉 提交于 2020-01-16 02:26:44
问题 I'm making a CGImage func otf() -> CGImage { which is a bezier mask on a gradient. So, // the path let p = UIBezierPath() p.moveTo etc // the mask let m = CAShapeLayer() set size etc m.path = p.cgPath // the layer let l = CAGradientLayer() set colors etc l.mask = m it's done. So then render a UIImage in the usual way ... UIGraphicsBeginImageContextWithOptions(sz.size, false, UIScreen.main.scale) l.render(in: UIGraphicsGetCurrentContext()!) let r = UIGraphicsGetImageFromCurrentImageContext()!

Error: Missing return in a closure expected to return 'UIViewController' (Xcode, Swift, iOS 13)

本秂侑毒 提交于 2020-01-14 07:01:11
问题 I'm getting the error: "Missing return in a closure expected to return 'UIViewController'" on the bolded line. How can I fix this? Thank you!! Var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { FirebaseApp.configure() let hasSession = UserDefaults.standard.value(forKey: "UserHasSubmittedPassword") as? Bool let vc: UIViewController = { if let hasSession = hasSession, hasSession ==

Swift 5 + kCCDecrypt (CommonCrypto): Failing to decrypt

一曲冷凌霜 提交于 2020-01-11 10:17:08
问题 Trying to write my own encrypt/decrypt functions in Swift 5 , based on tons of other similar questions -- and failing miserably. I'm using CommonCrypto + CCCrypt to encrypt/decrypt (AES, 256 key, random iv). I'm favouring NSData.bytes over withUnsafeBytes (which is just too confusing in Swift 5 ). My encrypt function goes like this: func encrypt(_ string: String) throws -> Data { guard let dataToEncrypt: Data = string.data(using: .utf8) else { throw AESError.stringToDataFailed } // Seems like

Can I use Swift 5 to build targets that are written in Swift 3

筅森魡賤 提交于 2020-01-06 04:28:25
问题 In early 2019 or late 2018 Apple will release Xcode 10.x with Swift 5. In my project I use a Cocoa pods which are written in Swift 3 and abandoned by the author. I would like to know if I have to replace the pods or upgrade or maybe I can leave them as they are. If Swift 5 will build targets written in Swift 3, I can continue to use pods written in Swift 3 as they are, if not, I how to upgrade/change it. Question: Does Swift 5 build targets that are written in either Swift 4 or Swift 3? 回答1:

Can a Swift Property Wrapper reference the owner of the property its wrapping?

人盡茶涼 提交于 2020-01-03 07:30:13
问题 From within a property wrapper in Swift, can you someone refer back to the instance of the class or struck that owns the property being wrapped? Using self doesn't obviously work, nor does super . I tried to pass in self to the property wrapper's init() but that doesn't work either because self on Configuration is not yet defined when @propertywrapper is evaluated. My use case is in a class for managing a large number of settings or configurations. If any property is changed, I just want to