dev:swift

Differences

This shows you the differences between two versions of the page.


Previous revision
dev:swift [2023/05/01 17:29] (current) – [SwiftUI] Henrik Yllemo
Line 1: Line 1:
 +<button type="primary" size="xs" icon="glyphicon glyphicon-bookmark">[[programming_lagugages| Programming Language]]</button> 
 +<nav type="tabs" justified="false">
 +  * [[:dev:xcode]]]]
 +  * [[:dev:swift]]
 +  * [[:dev:swiftui]]
 +  * [[:dev:objective-c]]
 +  * [[:kb:ios]]
 +  * [[:kb:macos]]
 +</nav>
 +====== Swift ======
 +Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. for iOS, macOS, watchOS, tvOS, Linux, and z/OS.
 +<data programminglanguage>
 +Full Name: Swift
 +Short Name: Swift
 +Description: Swift is a general-purpose, multi-paradigm, compiled programming language
 +Company: Apple Inc
 +Web: Yes
 +Mobile: Yes
 +Enterprise: Yes
 +Embedded : Yes
 +</data>
 +
 +<accordion>
 +<panel title='What is Swift?'>
 +Swift is a programming language developed by Apple for building applications for iOS, macOS, watchOS, and tvOS. Swift was designed to be fast, safe, and easy to use, and it is intended to replace Objective-C as the primary programming language for Apple's platforms.
 +</panel><panel title='What platforms can I build with Swift?'>
 +Swift can be used to build applications for iOS, macOS, watchOS, and tvOS. In addition, Swift can also be used to build server-side applications using frameworks such as Vapor and Kitura.
 +</panel><panel title='What are some of the key features of Swift?'>
 +Some of the key features of Swift include:
 +  * Optionals: a way of handling values that may be missing
 +  * Generics: a way of writing reusable code that can work with different types
 +  * Closures: a way of writing code that can be passed around and executed at a later time
 +  * Type inference: a way of allowing the compiler to infer the type of a variable based on its value
 +  * Automatic memory management: a way of managing memory automatically so that you don't have to worry about deallocating objects manually
 +</panel><panel title='Is Swift open source?'>
 +Yes, Swift was open sourced by Apple in 2015, and it is now maintained by the Swift community as well as Apple. The Swift source code is available on GitHub.
 +</panel><panel title='What are some popular frameworks and libraries for Swift?'>
 +Some popular frameworks and libraries for Swift include:
 +  * SwiftUI: a framework for building user interfaces for iOS, macOS, watchOS, and tvOS
 +  * Combine: a framework for handling asynchronous events and data streams
 +  * Alamofire: a library for handling network requests and responses
 +  * Kingfisher: a library for downloading and caching images
 +  * Realm: a database framework for iOS, macOS, watchOS, and tvOS
 +</panel><panel title='Can I use Swift with Objective-C?'>
 +Yes, you can use Swift and Objective-C together in the same project, and you can call Objective-C code from Swift and vice versa. This makes it easy to adopt Swift gradually in existing projects that use Objective-C.
 +</panel></accordion>
 +
 +
 +
 +{{wp>Swift_(programming_language)}}
 +<callout type="" title="GitHub Topics" icon="fa fa-github">
 +  * https://github.com/topics/swift
 +
 +Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns. Inspired by many other modern programming languages, Swift is intended to be more resilient and expressive than Objective-C, its predecessor.
 +</callout> 
 +
 +<callout type="" title="Free Programming Books" icon="fa fa-book">
 +  * [[https://www.programming-books.io/essential/swift/|Essential Swift]]
 +  * [[https://www.hackingwithswift.com|Hacking with Swift]]
 +  * [[https://goalkicker.com/SwiftBook/|Swift Notes for Professionals]]
 +  * [[https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/index.html|The Swift Programming Language]]
 +  * [[https://developer.apple.com/library/content//documentation/Swift/Conceptual/BuildingCocoaApps/index.html|Using Swift with Cocoa and Objective-C]]  
 +<WRAP column right><wrap lo>Source: [[https://github.com/EbookFoundation/free-programming-books/blob/main/books/free-programming-books-langs.md|EbookFoundation]]</wrap></WRAP>
 +</callout> 
 +
 +<jumbotron>
 +===== Hello World =====
 +
 +<sxh >
 + println("Hello, world!") // Swift 1.x
 +
 + print("Hello, world!"  // Swift 2.x
 +</sxh>
 +<WRAP column right><wrap lo>Source: [[https://en.wikibooks.org/wiki/Computer_Programming/Hello_world|Wikibooks]]</wrap></WRAP>
 +</jumbotron>
 + 
 +
 +==== SwiftUI ====
 +As of 2019, with Xcode 11, Apple has added a major new UI paradigm called **[[SwiftUI]]**. [[SwiftUI]] replaces the older Interface Builder paradigm with a new declarative development paradigm.
 +
 +  * https://developer.apple.com/xcode/swiftui/
 +
 +See also: [[dev:programming_lagugages]]
 +
 +
 +{{tag>Apple language programminglanguage dev-apple }}
 +
 +=== ## ToDo ## ===
 +  * FIXME
 +  * Optionals
 +  * Control structures
 +  * Functions
 +  * Closures
 +  * Object-oriented programming (OOP)
 +  * Classes
 +  * Inheritance
 +  * Polymorphism
 +  * Protocols
 +  * Extensions
 +  * Generics
 +  * Error handling
 +  * Defer statements
 +  * Memory management
 +  * ARC (Automatic Reference Counting)
 +  * Properties
 +  * Access control
 +  * Structs
 +  * Enums
 +  * Initializers
 +  * Control flow statements
 +  * Collection types
 +  * iOS development
 +  * SwiftUI framework
 +  * Combine framework