How to check if a string contains an int? -Swift

You can use Foundation methods with Swift strings, and that’s what you should do here. NSString has built in methods that use NSCharacterSet to check if certain types of characters are present. This translates nicely to Swift: var str = “Hello, playground1” let decimalCharacters = CharacterSet.decimalDigits let decimalRange = str.rangeOfCharacter(from: decimalCharacters) if decimalRange != nil … Read more

Manually triggering the iPhone/iPad/iPod keyboard from JavaScript

If your code is executed via something that was initiated via a user action then it will work. E.g; this works (pops keyboard): <input type=”text” id=’foo’><div onclick=’$(“#foo”).focus();’>click</div> this doesn’t work (input gets a border but no keyboard pop): <input type=”text” id=’foo’> <script> window.onload = function() { $(“#foo”).focus(); } </script>