UITextField text change event

How can I detect any text changes in a textField? The delegate method shouldChangeCharactersInRange works for something, but it did not fulfill my need exactly. Since until it returns YES, the textField texts are not available to other observer methods. e.g. in my code calculateAndUpdateTextFields did not get the updated text, the user has typed. … Read more

iOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 Beta

This crash has been a blocking issue I used the following steps to reproduce the issue: Create a Cocoa Touch Framework project Add a swift file and a class Dog Build a framework for device Create a Single View application in Swift Import framework into app project Instantiate swift class from the framework in ViewController … Read more

@selector() in Swift?

I’m trying to create an NSTimer in Swift but I’m having some trouble. NSTimer(timeInterval: 1, target: self, selector: test(), userInfo: nil, repeats: true) test() is a function in the same class. I get an error in the editor: Could not find an overload for ‘init’ that accepts the supplied arguments When I change selector: test() … Read more

Split a String into an array in Swift?

Say I have a string here: var fullName: String = “First Last” I want to split the string base on white space and assign the values to their respective variables var fullNameArr = // something like: fullName.explode(” “) var firstName: String = fullNameArr[0] var lastName: String? = fullnameArr[1] Also, sometimes users might not have a … Read more

#ifdef replacement in the Swift language

In C/C++/Objective C you can define a macro using compiler preprocessors. Moreover, you can include/exclude some parts of code using compiler preprocessors. #ifdef DEBUG // Debug-only code #endif Is there a similar solution in Swift? 18 s 18 Yes you can do it. In Swift you can still use the “#if/#else/#endif” preprocessor macros (although more … Read more