What are the supported Swift String format specifiers?

The format specifiers for String formatting in Swift are the same as those in Objective-C NSString format, itself identical to those for CFString format and are buried deep in the archives of Apple Documentation (same content for both pages, both originally from year 2002 or older): https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFStrings/formatSpecifiers.html https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html But this documentation page itself is incomplete, … Read more

Could not insert new outlet connection: Could not find any information for the class named

Here are some things that can fix this (in increasing order of difficulty): Clean the project (Product > Clean) Manually paste in @IBOutlet weak var viewName: UIView! // or @IBAction func viewTapped(_ sender: Any) { } and control drag to it. (Change type as needed.) Also see this. Completely close Xcode and restart your project. … Read more

Swift – How to convert String to Double

I’m trying to write a BMI program in swift language. And I got this problem: how to convert a String to a Double? In Objective-C, I can do like this: double myDouble = [myString doubleValue]; But how can I achieve this in Swift language?

Two-dimensional array in Swift

Define mutable array OR: OR if you need an array of predefined size (as mentioned by @0x7fffffff in comments): Change element at position OR Change sub array OR OR If you had 3×2 array of 0(zeros) before these changes, now you have: So be aware that sub arrays are mutable and you can redefine initial … Read more

What the meaning of question mark ‘?’ in swift?

You can use if and let together to work with values that might be missing. These values are represented as optionals. An optional value either contains a value or contains nil to indicate that the value is missing. Write a question mark (?) after the type of a value to mark the value as optional. If the optional value is nil, the conditional is false and the code … Read more

Date Format in Swift

You have to declare 2 different NSDateFormatters, the first to convert the string to a NSDate and the second to print the date in your format.Try this code: Swift 3 and higher: From Swift 3 NSDate class has been changed to Date and NSDateFormatter to DateFormatter.

type any? has no subscript members

When you subscript profile with “Addresses”, you’re getting an Any instance back. Your choice to use Any to fit various types within the same array has caused type erasure to occur. You’ll need to cast the result back to its real type, [[String: Any]] so that it knows that the Any instance represents an Array. Then you’ll be able to subscript it: This is very … Read more