ARC in Swift: Basics and beyond

RSS for tag

Discuss the WWDC21 session ARC in Swift: Basics and beyond.

View Session

Posts under wwdc21-10216 tag

3 Posts
Sort by:
Post not yet marked as solved
3 Replies
268 Views
Hello, I've been attempting to generate this code, but the last line returns an Expected declaration Error. class AboutMe { let firstName: String let lastName: String let age: Int init(firstName: String, lastName: String, age: Int){ self.firstName = firstName self.lastName = lastName self.age = age } var me: String { return "First Name: \(firstName), / Last Name: \(lastName), / Age: \(age)" } let myInfo = AboutMe(firstName: "NAME", lastName: "NAME", age: 10) print(myInfo) }
Posted
by Alzaabii.
Last updated
.
Post marked as solved
3 Replies
181 Views
As a swift noob, and coming from C++, I wonder why the following prints 'BOOM!!': var text = "" class ArrayHandle {     var array = Array()     init() {         text = "success"     }     deinit {         text = "BOOM!!"     } } struct Array { var buffer = Buffer() } struct Buffer { func doStuff() { print(text)} } var buffer = ArrayHandle().array.buffer.doStuff() Apparently the deinit is called before the text is printed... When you change the code to: var handle = ArrayHandle() handle.array.buffer.doStuff() it prints the expected 'success' Is there a way to force developers to use a var to store an object, or is that just a hidden bug that may fail in the future?
Posted
by Marleen70.
Last updated
.
Post marked as solved
1 Replies
170 Views
I want to import text from TextField(SwiftUI) in float format but I just have this error, the message said “Can’t turn the number of type ‘float’ to a unexpected type ‘Binding’”, if I try to run it will also send me the same error, how do I fix it?
Posted
by Bringker.
Last updated
.