swift3

Swift 3 custom URLProtocol crashes when converting Error to NSError

▼魔方 西西 提交于 2019-12-12 06:48:51
问题 I've got a rather large body of Swift 3 code for Mac OS 10.11 and up (using Xcode 8.2.1). There are a number of processes, among them a GUI application and a background service. Both of these use a custom URLProtocol , which is implemented in a framework (imported by both application and service). The protocol sometimes may generate instances of an enum that conforms to Error , which it catches and handles appropriately (generally by using the URLProtocolClient to toss them up to the

Stackview doesn't append second view

空扰寡人 提交于 2019-12-12 06:22:30
问题 I've created a stack view programmatically and I added a view which I've created programmatically too to it. But when I try to add a second view it doesn't work. Here's my code: @IBOutlet weak var codingScrollView: UIView! let codeStackView = UIStackView() var codeViews = [CodeView]() let codeView1 = CodeView(name: "Lennart", date: "13/05/2002", code: "Just some code") let codeView2 = CodeView(name: "Nina", date: "01/07/1999", code: "Also some code") The codingScrollView is the contentview I

how to dismiss alert view after validation?

浪子不回头ぞ 提交于 2019-12-12 06:16:41
问题 I had used SCLAlertView used for forgot password in this i had placed a textfield to enter email so that after making successful validation only it need to hide without this it should not hide can anyone help me how to implement this ? My code is shown below @IBAction func forgetPasswordButton(_ sender: Any) { let appearance = SCLAlertView.SCLAppearance(showCloseButton: true) let alert = SCLAlertView(appearance: appearance) let txt = alert.addTextField("Enter your emailid") _ = alert

CFDictionaryCreate crashes in Xcode 8 swift 3

不想你离开。 提交于 2019-12-12 06:08:57
问题 I have the following code for retrieving and storing RSAkeydata fileprivate func retrieveAndStoreRSAKeyData(isPublic: Bool) throws -> CFData { var resultCode = noErr var result: CFData let value = { if isPublic { let t = self.publicTag print(t) } else { let s = self.privateTag print(s) } } var keyCallbacks = kCFTypeDictionaryKeyCallBacks var valueCallbacks = kCFTypeDictionaryValueCallBacks let keys = [Unmanaged.passUnretained(kSecClass).toOpaque(), Unmanaged.passUnretained

Why 'if let' does not seem to unbox a value as before in Swift 3 in Xcode 8.3 beta?

人盡茶涼 提交于 2019-12-12 05:59:08
问题 Unlike before, I was surprised to see that 'title' is now an optional (the compiler now generates the waning : String interpolation produces a debug description for an optional value; did you mean to make this explicit?). How it comes the 'if let title =' expression does no unbox it anymore? What should I do to unbox in the if? // Go thru all publication where the tag has been found for item in items { if let item = item as? [String: String?], let title = item["label"] { i += 1 if let

How can I fit x-axis labels according with its bar?

夙愿已清 提交于 2019-12-12 05:49:56
问题 I am using ios-chart library and I have a CombinedBarChart in which I made zoom on it by default combinedBarChart.setScaleMinima(2, scaleY: 1) combinedBarChart.setScaleEnabled(false) I would like that each x-axis label will stay above each bar but I cannot make it work properly. Here is my example: As you can see, x-axis labels does not correspond with their bars respectively. How can I make that each x-axis label will be above of its bar? Thanks in advance! 回答1: I was not able to reproduce

Error Domain=NSOSStatusErrorDomain Code=-12780 \“(null)\”

放肆的年华 提交于 2019-12-12 05:49:13
问题 When I try to export the asset with AVAssetExport I get the following error only on videos received through whatsapp probably. I could not find a working solution. I've also tried implementing code to fix video duration, but I did not fix it. Error is : Error Domain=NSOSStatusErrorDomain Code=-12780 \"(null)\" Here code PHCachingImageManager().requestAVAsset(forVideo: asset.phAsset!, options: nil, resultHandler: { (AVAssetRecivied, audioMix, info) in let AVAssetMy = AVAssetRecivied!

Dynamic Height Calculation of UITableViewCell depend upon TextView's height

若如初见. 提交于 2019-12-12 05:48:19
问题 I have given the leading and trailing to textview inside content of tableview . I want to dynamically calculate the height of Tableviewcell. the height calculation is working fine sometimes but sometimes not working particular devices like 5c. i have used following code to estimate the height of text : func estimateFrameForText(text: String) -> CGRect { let size = CGSize(width: self.view.frame.size.width, height: 10000000) let options = NSStringDrawingOptions.usesFontLeading.union(

Controlling website within Xcode/ Swift UIWebView

烈酒焚心 提交于 2019-12-12 05:48:15
问题 I have created a very simple app which directs the user to a web app... one of the pages within the app allows you to search store stock for various different stores (store number entered manually or the nearest store located automatically) and then asks the user to enter the appropriate barcode... within the app I have therefore added a barcode scanner (a separate view controller) which captures the barcode and then returns to the uiwebview... but how can I automatically enter that barcode

Swift 3 - CollectionView data source did not return a valid cell

僤鯓⒐⒋嵵緔 提交于 2019-12-12 05:48:04
问题 I am using this code: https://www.youtube.com/watch?v=bNtsekO51iQ , but when I implement my data and use collectionView.reloadData() it crashes with error code *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the collection view's data source did not return a valid cell from -collectionView:cellForItemAtIndexPath: for index path <NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}' class ChatLogController: UICollectionViewController,