About 46,100,000 results
Open links in new tab
  1. Convert Int to String in Swift - Stack Overflow

    I'm trying to work out how to cast an Int into a String in Swift. I figure out a workaround, using NSNumber but I'd love to figure out how to do it all in Swift. let x : Int = 45 let xNSNumber = ...

  2. swift - Read and write a String from text file - Stack Overflow

    I need to read and write data to/from a text file, but I haven't been able to figure out how. I found this sample code in the Swift's iBook, but I still don't know how to write or read data. import...

  3. Swift: Convert enum value to String? - Stack Overflow

    The original question's title is "Swift: Convert enum value to String?" but most of the other answers told how to create enums with strings associated to values, so did not really …

  4. xcode6 - Rounding in Swift with round () - Stack Overflow

    While playing around, I found the round() function in swift. It can be used as below: round(0.8) Which will return 1, as expected. Here's my question: how do I round by thousandths in swift? I ...

  5. Can I mix Swift with C++? Like the Objective-C .mm files

    Swift doesn't have the same relationship. It is not a superset of C or C++, and you can't directly use either in a .swift file. "Using Swift with Cocoa and Objective-C" also tells us: You cannot …

  6. swift2 - Swift: guard let vs if let - Stack Overflow

    The Swift Docs on Control Flow explain the idea behind that: Using a guard statement for requirements improves the readability of your code, compared to doing the same check with …

  7. swift - How to get the current time as datetime - Stack Overflow

    With Swift 5, Foundation offers many ways to get the hour value from a Date object. According to your needs, you may choose one of the four following Playground code snippets.

  8. Split a String into an array in Swift? - Stack Overflow

    Split is a native Swift method introduced in Swift 4, and it returns an array of Substring values. On the other hand, components are part of the NSString class and return an array of String …

  9. Add an element to an array in Swift - Stack Overflow

    (And in really old Swift versions, could append single elements, not just other collections of the same element type.) There's also insert(_:at:) for inserting at any index. If, say, you'd like a …

  10. Swift - How to replace characters in a String? - Stack Overflow

    I am looking for a way to replace characters in a Swift String. In this example String: "This is my string" I would like to replace the spaces, " ", with "+" to end up...