Questions tagged [swift4.1]

Use this tag only for questions directly related to changes in version 4.1 of Apple's Swift programming language. Use the tag [swift] for more general language questions, or the tags [ios], [cocoa], [apple-watch] etc. for questions about developing on Apple platforms.

Swift 4.1 contains updates to the core language, including more support for generics, new build options, as well as minor enhancements to Swift Package Manager and Foundation. There was also significant progress made in stabilizing the ABI.

Swift 4 is the fourth version of the Swift language developed by Apple that was released in 2017. The language is open source and available on Github (see ).

The development of Swift 4 and its goals can be viewed on the Swift Programming Language Evolution repository on GitHub

229 questions
2
votes
2 answers

"Neither element nor any descendant has keyboard focus" when running XCTestCase in a real iPhone

I'm trying to run a UI test case where there are two input fields exists. Following is my code let usernameTextField = app.webViews.otherElements["Identity Server"].textFields["Username"] let passwordField = app.webViews.otherElements["Identity…
AnujAroshA
  • 4,623
  • 8
  • 56
  • 99
2
votes
1 answer

How to understand the some("a value") in Swift 4.1

Here is the screenshot of my Xcode Playground: As you can see, the str is printed as some("Hello"). This really confuses me as there seems to be no documentation on it. Dose anyone have a good explanation for this some()? System info: swift…
wzso
  • 3,482
  • 5
  • 27
  • 48
2
votes
2 answers

Module compiled with Swift 4.1 cannot be imported in Swift 4.1.50

I'm using AudioKit 4.3 in XCode 10 but I'm running into this problem while building
Shawn Ma
  • 41
  • 1
  • 5
2
votes
1 answer

Swift 4.1 - Cannot convert value of type [Character] to [String]

My code was supporting Swift 3.3 before, now I'm upgrading it to Swift 4.1 using Xcode 9.3. It shows me the following error while trying to build my project. Here is code for JSON parsing // MARK: Store JSON initializer convenience…
Pramod More
  • 1,220
  • 2
  • 22
  • 51
2
votes
2 answers

How to get the value of url parameter using swift 4.1

I am trying to get parameters for urls and I try to get only the date not time the URL. http://aa.no-ip.biz:8001/hf_tracker/api/history.php?accesskey=12345&Vehilce=1618&FromDate=2018-05-10 13:11&ToDate=2018-05-14 12:11 Code: extension URL { …
Rehan Meo
  • 61
  • 2
  • 9
2
votes
2 answers

check internet connection currently for all pages in swift 4.1

There is one viewController. What should i write in AppDelegate.swift file in didFinishLaunchingWithOptions scope ? PART 1 AppDelegate.swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:…
mannyCalavera
  • 593
  • 1
  • 4
  • 23
2
votes
1 answer

Type 'String' has no member 'documentType' Swift 4.1

In Swift4.1 and Xcode 9.3.1 I am getting error Type 'String' has no member 'documentType' do { let modifiedFont = NSString(format:"%@" as NSString, string)…
niravdesai21
  • 4,818
  • 3
  • 22
  • 33
2
votes
2 answers

Why my animation is not smooth?

I'm trying to animate a textfield with a custom class, when I change my left constraint from 0 to (self.bounds.width - self.bounds.width/3) the animation is not smooth, but when I set it back to 0 it works perfectly. Here is part of my custom…
Sergio Trejo
  • 632
  • 8
  • 23
2
votes
2 answers

SF Pro Text Medium font is not found in swift code

I'm using xCode 9.3.1 & Swift 4.1. I'm trying to use SF Pro Text Medium font in my app code programatically. But this font is not found in the source code in swift file and app crashes. Here is the code: NSAttributedStringKey.font: UIFont(name:…
Matt
  • 315
  • 2
  • 6
  • 20
2
votes
1 answer

Error while accessing private array inside class

I am getting an error message when I try to access the private array (arr) inside the class (MyArray). What I am trying to achieve is to create a closure for reversing the array contents and this closure can be called from outside the class using…
vermau
  • 75
  • 1
  • 8
2
votes
2 answers

Tone is not playing in Audikit 4.2 but in version 4.1 working fine

I am using Audiokit in my project and recently I updated my Xcode 9.3. It says i need to update Audiokit as well. But when I updated, it seems I need to use try catch to start and stop audio kit. this is fine. oscillator = AKFMOscillator() …
Maulik Vekariya
  • 554
  • 7
  • 19
2
votes
1 answer

Swift 4.1 compactMap for lazy collections

Prior to the Swift 4.1 I used flatMap to remove nil values from collections. Now this method is deprecated and I need to replace it with compactMap. Sometimes I used flatMap with lazy collections to optimise my code, like that: let optionalIntegers…
Roman Podymov
  • 4,168
  • 4
  • 30
  • 57
2
votes
2 answers

Google Directions Api URL returning nil

I am trying to get directions using the Google directions api. Everything I have done so far works. I have search functionality that saves the searched location (using Google's suggested locations) then it places a marker there. I just added some…
insta catering
  • 151
  • 2
  • 12
2
votes
1 answer

Bad access when creating NSPredicate instance

So this is the code which worked in Xcode 9.2: let request: NSFetchRequest = MyModel.fetchRequest() request.predicate = NSPredicate(format: "saved = %@", true as CVarArg) and after update to Xcode 9.3 and Swift 4.1, the code…
Whirlwind
  • 14,286
  • 11
  • 68
  • 157
2
votes
2 answers

A weak property in Objective-C class implementing a Swift protocol

In Swift 4.1, weak properties have been deprecated in protocols, since the compiler has no way to enforce it. It is the responsibility of the class conforming to the protocol to define the memory behaviour of the property. @objc protocol MyProtocol…
KPM
  • 10,558
  • 3
  • 45
  • 66