How to play a sound using Swift?

Most preferably you might want to use AVFoundation. It provides all the essentials for working with audiovisual media. Update: Compatible with Swift 2, Swift 3 and Swift 4 as suggested by some of you in the comments. Swift 2.3 Swift 3 Swift 4 (iOS 13 compatible) Make sure to change the name of your tune as well as the extension. The file needs to … Read more

Swift: print() vs println() vs NSLog()

A few differences: print vs println:The print function prints messages in the Xcode console when debugging apps.The println is a variation of this that was removed in Swift 2 and is not used any more. If you see old code that is using println, you can now safely replace it with print.Back in Swift 1.x, print did not add newline characters at the end of … Read more

Prepare for Segue in Swift

This seems to be due to a problem in the UITableViewController subclass template. It comes with a version of the prepareForSegue method that would require you to unwrap the segue. Replace your current prepareForSegue function with: This version implicitly unwraps the parameters, so you should be fine.

“Unrecognized selector sent to instance” in swift

I have no idea what I am doing wrong. I am also quite new to programming so I am not very good at debugging. This was a test app so that I can see how swift ties in with app development. So far, I have got this: I am getting the error “Unrecognized selector sent … Read more

How to create a global variable?

From the official Swift programming guide: Global variables are variables that are defined outside of any function, method, closure, or type context. Global constants and variables are always computed lazily. You can define it in any file and can access it in current module anywhere. So you can define it somewhere in the file outside of any scope. … Read more

Error in Swift class: Property not initialized at super.init call

Quote from The Swift Programming Language, which answers your question: “Swift’s compiler performs four helpful safety-checks to make sure that two-phase initialization is completed without error:” Safety check 1 “A designated initializer must ensure that all of the “properties introduced by its class are initialized before it delegates up to a superclass initializer.” Excerpt From: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)