Xcode 9 update Swift, purple warning

Not sure why after updating to Xcode 9 my project (originally created in Swift 3) is showing purple warnings: UITextField.text must be used from main thread only I'm only checking in If statement if text field is empty... attaching screenshot. ...
more »

2017-09-29 15:09 (5) Answers

Swift/Cocoa: Sort the data of a column

In Swift 4, when I try to sort a column by clicking its header, nothing happens : Here's my code: import Cocoa class ViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate { var persons = [Person(name: "John", age: "30"), P...
more »

2017-09-29 14:09 (0) Answers

swift generic dictionary function

I am trying to create a generic function for dictionary(of any data type). I get this error though when I call the function: error: cannot convert value of type '[Int : String]' to expected argument type '[_ : _]' wprintgeneric(inp: w) ...
more »

2017-09-29 10:09 (1) Answers

How to read MIME type of a page with WKWebView?

My app navigates to a mobile web page with a WKWebView. What I'm looking for is how to check whether or not the web page is downloadable (e.g. a .csv or .pdf). Right now, I'm doing something hacky to read the URL, but I know there must be a more eleg...
more »

2017-09-28 22:09 (2) Answers

.joined(separator:) in Swift 4/XCode 9?

I am writing UITests and recently updated to Xcode 9. This line of code throws an error: let deleteString = stringValue.characters.map { _ in XCUIKeyboardKeyDelete }.joined(separator: "") The error on this line is with .joined(separator:) and say...
more »

2017-09-28 20:09 (1) Answers

How can i get Local DateFormat with swift?

I have CEST dates in yyyy-MM-ddTHH:mm:ssZ format. I want to show them in local format. The following function works fine. It shows the time correctly. But in the end I am forced to show the date in "dd.MM.yyyy HH:mm" format. How can i get Local/nati...
more »

2017-09-27 23:09 (2) Answers

Why does `pod install` change the PODS_ROOT path?

Whenever I run pod install, CocoaPods tries to change the PODS_ROOT/... to PODS_PODFILE_DIR_PATH/... in the build phase. I'm not sure why this value is changing just for my Cocoapods setup and not for my other team members. Does anyone know why this...
more »

2017-09-27 19:09 (1) Answers

View controller gets pushed with wrong frame

This bug surfaced with iOS 11, and is related to the new, slightly taller UISearchBar provided by UISearchController. It's best explained by this very compressed gif. As you can see, when the hexagon page pushes a view controller, it the view contr...
more »

2017-09-27 15:09 (0) Answers

UIView Shadow Gradient

I have created a custom UIView in my iOS project that has a drop shadow. I want the shadow to have the same gradient colour as the view's background. Below is an example of how my current solid colour shadows look. This is done through a subclass ...
more »

2017-09-27 12:09 (0) Answers

Can cast T to comform a protocol in swift

I want use swift generic as code show below: func handle<T>(data: Data, with type: T.Type) { if type is B.Type { handleOne(data: data, with: type) //error here: In argument type 'T.Type', 'T' does not conform to expected type 'B...
more »

2017-09-27 10:09 (1) Answers

check if user has sent the mail successfully

I working with swift 4 for macOS. I know that I can get the "success result" of a print operation and can check if the user has sent the print job or canceled it with this code: let printOp = NSPrintOperation() printOp.runModal(for: view.window!, d...
more »

2017-09-27 10:09 (0) Answers

Alternative to override extension's method

I want to extend UIView by adding some functions, and override them in any subclass of UIView that I want. I found in apple documentations that I can't override extensions (and the compiler will complain) which make some sense. So I need someone to ...
more »

2017-09-27 10:09 (1) Answers

Mapkit rendererForOverlay bug

When using Mapkit's renderer for overlay, I'm experiencing an odd bug where the line pattern is not even on the map, some portions of the line are smaller than others (see attached image). I've also experienced another issue where the dots become eno...
more »

2017-09-27 03:09 (0) Answers

iOS 11: self.performSegue() not working

i started the migration to Xcode 9 & iOS 11 build today. in my storybased app, the following code: self.performSegue(withIdentifier: Const.UI.Segue.showIntro, sender: self) runs fine in all previous iOS (just verified with iOS 10.3, 10.0, 9.0...
more »

2017-09-26 22:09 (0) Answers

Will DispatchQueues wait for each other?

I have a function I'm trying to make in Swift (X-Code). I'm basically sending a few commands over bluetooth and I have a question about how the Main Asyncafter works. Here's my set-up code: func tPodSetUp() { var delayForResponse = Dispa...
more »

2017-09-26 21:09 (1) Answers

moving platform with gameplay kit

Creating a 2d game, and want to add moving platforms where I can control the pattern and rotation of the platform. Example: I want this platform to move in a clockwise motion, also when it reaches the top and bottom I want it to rotate accordingl...
more »

2017-09-26 18:09 (1) Answers