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
3 answers

vapor build error: manifest parse error(s)

macOS Height Sierra 10.13.4 Xcode version 9.3 $ swift --version Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1) Target: x86_64-apple-darwin17.5.0 $ brew info vapor vapor/tap/vapor: stable…
xac
  • 310
  • 3
  • 9
2
votes
1 answer

Swift 4.1 array protocol conformance

We just switched to swift 4.1 and we are having some difficulties with type conformance for Arrays. Here is the old way: public typealias XDRCodable = XDREncodable & XDRDecodable public protocol XDREncodable: Encodable { func xdrEncode(to…
Jelly
  • 4,522
  • 6
  • 26
  • 42
1
vote
1 answer

compactMap behaves differently when storing in an optional variable

Consider the following array. let marks = ["86", "45", "thiry six", "76"] I've explained my doubts in the following two cases. Case#1 // Compact map without optionals let compactMapped: [Int] = marks.compactMap { Int($0)…
Shashank Mishra
  • 1,051
  • 7
  • 18
1
vote
1 answer

How to check camera rotation left or right side in ARkti

i need tho check that user move his camera left or right side in ARkit. this is my code func renderer(_ renderer: SCNSceneRenderer, willRenderScene scene: SCNScene, atTime time: TimeInterval) { //get camera position guard let…
balkaran singh
  • 2,754
  • 1
  • 17
  • 32
1
vote
1 answer

How to test for undefined array?

I am using this line of code let transactions = SKPaymentQueue.default().transactions This is what Apple amazing docs has to say about transactions. What is exactly "undefined"? How do I test transactions before proceeding in code? I have an…
Duck
  • 34,902
  • 47
  • 248
  • 470
1
vote
1 answer

How to make Array equatable?

I have a following decodable class: class Sample: Decodable { var something: Array? } extension Sample: Equatable { static func == (lhs: Sample, rhs: Sample) -> Bool { return rhs.something ?? [] == lhs.something ?? [] …
TechnoGeezer
  • 197
  • 2
  • 2
  • 14
1
vote
1 answer

IOS WKWebView - Hide website Header & Footer

How can i hide header and footer through loading url using Wkwebview ? Most probably to pass some param or cookies that webpage read and take action against. class TermCond_PrivacyPoli_VC: UIViewController , WKNavigationDelegate, WKUIDelegate…
1
vote
0 answers

How to Encode & to %26 in Swift 4.1

How to Encode the & to %26 in Swift 4.1? This is what I tried: func encodeString(string: String) -> String { let unreserved = "!@#$%^&*()_+<>?:,.;'*" let allowed = NSMutableCharacterSet.symbol() allowed.addCharacters(in: unreserved) …
Anik
  • 61
  • 8
1
vote
2 answers

How to suppress "variable was never used" warning if I have to keep the target object alive in Swift?

Sometimes, I have to keep a class instance alive without explicit named reference to it. For example, in this code, compiler complains. let a = AAA() // "... `b` never used" warning. let b = a.bbb() a.ddd(333) But if I replace b with _, now the…
eonil
  • 83,476
  • 81
  • 317
  • 516
1
vote
1 answer

Map function changes in Xcode 10

I have a variable declared as var noOfPlayers: [PlayerDetail]! Now let's say I have the property declared as var playerReadyStatus: Bool = true inside PlayerDetail. Now for each element inside noOfPlayers, I want to change this property of…
Francis F
  • 3,157
  • 3
  • 41
  • 79
1
vote
1 answer

Query in firebase Database in iOS

I work with firebase database, I have the following data, I need to get all groups names (GName) of a user by his phoneNum, i.e. all groups of specific user, How can I get that in swift 4?
Ali A. Jalil
  • 873
  • 11
  • 25
1
vote
2 answers

UIKeyboard not appearing when tapping on UITextField in my app

In my app I have some UITextFeilds but when I run my app and trying to write I can't see the keyboard. I tried this answer, but probably my xcode version isn't the same as there, I'm using xcode9.
trycatch
  • 135
  • 1
  • 8
1
vote
2 answers

why we use return true or false in appDelegate?

In this method what is the means of true and false? application: didFinishLaunchingWithOptions: -> Bool{ return true } if I write return true application Launch and works fine either I write return false application work's fine. so what is the…
Ravindra_Bhati
  • 1,071
  • 13
  • 28
1
vote
2 answers

Conditional Protocol Conformance: Cannot convert value of type 'Array<_>' to specified type '[UInt8]'

Trying to extend an Array, String and Dictionary in Swift 4.1 using conditional conformance but am running into a dead end when trying to initialize an array with Elements that are conforming to the Decodable/Encodable through a custom protocol…
dandoen
  • 1,647
  • 5
  • 26
  • 44
1
vote
0 answers

Push notifications in iOS11 (Xcode 9 swift 4)

How can I get push notifications on iOS11 in the background? I tried this and never succeeded. Why when in the foreground does a notification appear while in the background it doesn't appear? Is there something missing with my source code or…
Syahrir
  • 109
  • 3
  • 10