Swiftの基本的な概念について学び、データ競合のない並行コードを実現する方法を知りましょう。
従来、可変状態(mutable state)は、細心の注意を払い、実行時の同期によって手動で保護する必要がありました。
import SwiftUI | |
struct ContentView: View { | |
@Environment(\.colorScheme) var scheme | |
private let date = Date() | |
private let colors = [Color.green, .pink, .blue, .orange, .purple] | |
private let titles = ["NEON", "GLOW", "LIGHT", "SHINE", "BRIGHT"] | |
var body: some View { | |
TimelineView(.animation) { context in |
import SwiftUI | |
struct Card: Identifiable, Hashable { | |
let id = UUID() | |
let creditID = UUID() | |
let colors: [Color] | |
let name: String | |
let number: String | |
} |
import RealityKit | |
import SwiftUI | |
struct PointLightsInsideContainerView: View { | |
@State private var rootEntity: Entity? | |
@State private var timer: Timer? | |
@State private var spherePositions: [String: SIMD3<Float>] = [:] | |
@State private var sphereTargetPositions: [String: SIMD3<Float>] = [:] | |
@State private var rotationAngle: Float = 0 | |
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
TextSampleView(style: .foreground) | |
TextSampleView(style: .mint) | |
TextSampleView(style: linearGradient) | |
} | |
.font(.largeTitle) |
import SwiftUI | |
import Observation | |
struct ContentView: View { | |
@State private var model = MazeObject(width: 39, height: 39) | |
@State private var resetID = UUID() | |
@State private var disabled = false | |
var body: some View { | |
VStack { |
import RealityKit | |
import SwiftUI | |
struct GlowingSphere: View { | |
@State private var opacity: Float = 1.0 | |
@State private var isForward: Bool = false | |
var body: some View { | |
GeometryReader3D { proxy in | |
RealityView { content in |
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
ScrollView(.vertical) { | |
ForEach(0..<1000) { i in | |
RoundedRectangle(cornerRadius: 24) | |
.fill(.blue) | |
.frame(height: 100) | |
.padding(.horizontal) |
import RealityKit | |
import SwiftUI | |
import GameplayKit | |
struct MorphingSphereRealityView: View { | |
@State private var currentEntity: Entity? | |
@State private var morphFactor: Float = 0.0 | |
@State private var frameDuration: TimeInterval = 0.0 | |
@State private var lastUpdateTime = CACurrentMediaTime() | |
import SwiftUI | |
struct AnimatingMaskedMeshView: View { | |
let referenceDate: Date = .now | |
@State private var mainPosition: CGPoint = .zero | |
@State private var positions: [CGPoint] = [] | |
private let blurRadius = 20.0 | |
private let alphaThreshold = 0.875 |
Swiftの基本的な概念について学び、データ競合のない並行コードを実現する方法を知りましょう。
従来、可変状態(mutable state)は、細心の注意を払い、実行時の同期によって手動で保護する必要がありました。