CS193p Notes — Lecture 7: Multithreading EmojiArt

Colors and Images

Multithreaded Programming (6:15)

let queue = DispatchQueue.main or Dispatch.global(gos: )
queue.async { }

EmojiArt Demo (20:38)

View

import SwiftUIstruct EmojiArtDocumentView: View {
@ObservedObject var document: EmojiArtDocument
var body: some View { }
}

ModelView

import SwiftUIclass EmojiArtDocument: ObservableObject {}
struct EmojiArt {
var backgroundURL: URL?
var emojis: [Emoji]()
struct Emoji: Identifiable {
let text: String
var x: Int
var y: Int
var size: Int
let id: Int
fileprivate init(text: String, x: Int, y: Int, size: Int, id: Int) {
self.text = text
self.x = x
self.y = y
self.size = size
self.id = id
}
}

private var uniqueEmojiId = 0
mutating func addEmoji(_ text: String, x: Int, y: Int, size: Int) {
uniqueEmojiId += 1
emojis.append(Emoij(text: text, x: x, y: y, size: size, id: uniqueEmojiId))
}
}

https://twitter.com/reallankinen

Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5
Lecture 6
Lecture 7
Lecture 8
Lecture 9
Lecture 10
Lecture 11
Lecture 12
Lecture 13
Lecture 14

Originally published: https://www.notion.so/lankinen/Lecture-7-Multithreading-EmojiArt-f84d41f0006b459ab3bd217fde989e1d