Starting with Swift Swift UI

Swift syntax


struct Game{
    let title: String
    let version: Double
    init(title theTitle: String, version theVersion: Double ) {
        self.title = theTitle
        self.version = theVersion
    func play(){
        print(self.title + " is playing.....")
let MyGame = Game(title: "MyFirstGame", version: 0.1) // MyFirstGame is playing.....


Supports interfaces in Java

protocol Updatable{
    func update(_ version: Double)

struct Game: Updatable{
    func update(_ version: Double) {

Structure name: Protocol name

SwiftUI Based on this, quoted from ContentView.swift

struct ContentView: View {
    var body: some View {
        Text("Hello, world!")

In other words, the ContentView structure is defined using the View protocol. The View protocol needs to implement the body property, so that's right. The some type is an arbitrary type that conforms to the View protocol, so it does not necessarily have to be a View.

Recommended Posts

Starting with Swift Swift UI
Progress made with Swift UI
Swift UI 100 knocks
Customize View with View Modifier in Swift UI
I tried using Realm with Swift UI
Shiritori map app made with Swift UI
Swift UI TextView placeholder
DataNucleus starting with Gradle
Getting Started with Swift
CarPlay starting with iOS14
[Swift] Create an image selection UI with PhotoKit
Incorporate View created with Swift UI into ViewController
Display 3D objects of SceneKit with Swift UI, etc.
GraphQL Client starting with Ruby
Execute external command with swift
Photo library in Swift UI
Spring Boot starting with copy
Spring Boot starting with Docker
[Swift UI] Use Map view
Compare Java 8 Optional with Swift
[Swift 5] Implement UI for review function
Implementing side menus in Swift UI
Swift beginner Debugging memo with Xcode
(For beginners) Swift UI view element collection
Start UI testing with Dagger2 and Mockito
ARC104 B --Solve DNA Sequence with Swift!
Manage View status with enum in Swift
[Swift 5] Implementation of membership registration with Firebase
[Swift5] Round the acquired image with UIImagePicker
Getting Started with Java Starting from 0 Part 1
AWS Lambda with Java starting now Part 1
[Swift] Easy to implement modal with PanModal