Swift Pages

Dot Net Perls has example pages for many languages, with explanations and code side by side (for easy understanding).
C#F#GoJavaJSPythonRubyScalaSwiftVB.NETWindowsWPF
2D array. Use 2D arrays: assign elements and loop over multidimensional arrays. See the syntax for 2D arrays.Swift 2D Array Examples
Array. Use int and string arrays. Append to arrays, loop over elements and modify arrays.Swift Array Examples, String Arrays
Convert. Convert Strings to Ints and Ints to Strings. Handle invalid string data and optionals.Swift Convert String to Int Example
Dictionary. Use a dictionary to look up values from keys. Add elements and loop over tuples with for-in.Swift Dictionary Examples
File. Use Foundation, NSString and the contentsofFile argument to read a text file into a string.Swift File (Read Text File Into String)
Find, range. Use range and contains to search for strings within other strings. Find a word in a string.Swift Find Strings: range of Example
For-loop. Use the for-in loop and the enumerated method. See the while and repeat while loops.Swift Loops: for, repeat and while Examples
If. Use an if-else statement. Conditions in an if evaluate to true or false.Swift If, If Else Example
Inout, parameters. Use the inout keyword for an argument in a func. Inout means an output parameter.Swift inout Keyword: Func Example
Int. Use the Int type and the Int.max and Int.min properties. Test Ints with MemoryLayout.Swift Int Examples: Int.max, Int.min
Keywords. Review keywords in the Swift language. These keywords are used throughout Swift programs.Swift Keywords
Lower, uppercase. Use the lowercased and uppercased methods. Capitalize words with capitalized.Swift Lower, Uppercase and Capitalized Strings
Math. Use math methods. Call abs, max, min, sqrt, floor, ceil and pow.Swift Math: abs, sqrt and pow
Optional. Use optional values. An optional may be nil, which means it has no value.Swift Optional: Nil Examples
Print. Use the print method to display strings and other values to the console.Swift Print: Lines, Separator and Terminator
Properties. Store values with properties. Use get, set, lazy and the willSet and didSet observers.Swift Property Examples
Range. Use ranges with startIndex and endIndex. Call the index func and specify offsetBy.Swift Range Examples (index, offsetBy)
Remove duplicates. Use funcs, and the filter method, to remove duplicate elements from arrays.Swift Remove Duplicates From Array
Replace. Call replaceSubrange to replace strings. Use replacingOccurrences and replacingCharacters.Swift Replace String Example
Sort. Sort arrays with the sort method. Use funcs and closures to compare Strings and Ints.Swift Sort String Arrays: Closure Examples
Split. Use components separatedBy to split a string into an array. Split with a string or characters.Swift Split Strings Example (components)
String length. Get the length of a string with the endIndex property. Loop over the chars based on indexes.Swift String Length
String range, substring. Get a substring from a string with a range. Use index, startIndex and offsetBy.Swift Substring Examples
String. Use strings and string literals. See a list of string methods that can be called.Swift String
Switch. Use the switch statement with cases and the default and fallthrough keywords.Swift Switch Statements: case, default and fallthrough
© 2007-2019 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.
HomeSearch
Home
Dot Net Perls