Post

Replies

Boosts

Views

Activity

Reply to developing a camera app(self timer, camera timer, delayed shooting))
This question seems to be just a duplicate of another post of yours. Generally, when any of your question could not get good responses, duplicate posts would not considered to be a good manner. And do everything for me-type questions are not preferred. To get better responses sooner, you should better include as much info as you can explaining what you have learnt till now. Frankly, posts including codes would get more responses even when the code is incomplete.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Cannot convert value of type 'Task.Type' to expected argument type 'Task'
Please use the Code Block feature of this site when showing your code. (Or you can enclose each code block with lines containing only ``` manually.) And the last line of the DetailsView.swift in your shown code is a closing brace (}) and it lacks another closing brace. I guess the line you get the error is: DetailsView(task: Task) Then the cause of the error is obvious. When you use DetailsView(task:), you need to pass an instance of Task to the parameter task:, but you are just writing the type name Task. Please try changing the line as follows: DetailsView(task: Task(name: "Make home work - Science", isComplete: false, lastCompleted: nil))
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to textSelection(_:) too basic
As far as I tried (and read some blogs), in the current implementation of SwiftUI, users can just select all the text where textSelection(.enabled) is applied. You can send an enhancement request using the Feedback Assistant.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Xcode10/Swift on Mac OS 10.13.6??? (Mountain Lion)
developing a new App for iOS/iPadOS/macOS If you are planning to develop apps for App Store, you cannot use the old iMac. App Store submission update iPhone and iPad apps. Starting April 26, 2021, all iPhone and iPad apps submitted to the App Store must be built with Xcode 12 and the iOS 14 SDK or later. So, you need a Mac capable of running Xcode 12 which requires macOS Catalina 10.15.4 or later. Minimum requirements and supported SDKs The iMac (21.5in, mid-2011) is not supported. macOS Catalina - Technical Specifications ... Mac Hardware Requirements ... Mac mini (Late 2012 or newer) ...
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to Type 'ToggleStyle' has no member 'switch'
after i upgraded Xcdoe 13 beta to Xcode 13 i lost ability to build for 12.0 Please check the Software Download page of Xcode 13 Applications Xcode 13 Xcode 13 includes everything you need to create and submit apps to the App Store for all Apple platforms. It Includes the SDKs for iOS 15, iPadOS 15, watchOS 8, tvOS 15, and macOS Big Sur. To continue developing apps for macOS Monterey, use Xcode 13 beta 5. i can't event download Xcode-beta 13 You can download Xcode 13 beta 5 from the link on the page above, or you can download older Xcodes from the More Download pages. Or you can use SwitchToggleStyle() explicitly: Toggle(isOn: $isOn) { Text("IPv6") } .toggleStyle(SwitchToggleStyle())
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Adding MapPin to SwiftUI Tutorial MapView.swift
So, Place and annotations are declared inside struct MapView and coordinate is a property of MapView. You should better include all such info in the original post. Generally, when you show your code, you should better show the whole file of interest, that helps readers check what's going on. As the error message is clearly stating, in your code on the line initializing the instance property annotations, you are trying to use another instance property coordinate, which is not permitted in Swift. One possible solution would be initializing annotations somewhere else than the property initializer. struct MapView: View { var coordinate: CLLocationCoordinate2D @State private var region = MKCoordinateRegion() struct Place: Identifiable { let id = UUID() let name: String let coordinate: CLLocationCoordinate2D } @State var annotations: [Place] = [] //<- var body: some View { Map(coordinateRegion: $region, annotationItems: annotations) { MapPin(coordinate: $0.coordinate) } .onAppear { setRegion(coordinate) //↓ annotations = [ Place(name: "Xyz", coordinate: CLLocationCoordinate2D(latitude: coordinate.latitude, longitude: coordinate.longitude)) ] } } private func setRegion(_ coordinate: CLLocationCoordinate2D) { region = MKCoordinateRegion( center: coordinate, span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2) ) } }
Oct ’21
Reply to iOS 15 - New JSONDecoding Decimals issue
It looks like there is a conversion to double in between or so? True. As you know, JSON is based on JavaScript Object Notation and numeric values in JavaScript are represented in 64-bit binary floating point -- Double. So, many JSON libraries might be using Double as an internal representation of JSON number. So, you should better not rely on the result of conversion using Decimal even in Xcode 12. Please try this: import Foundation struct DTO: Decodable { let amount: Decimal // Please code in the following lines and try it later... // enum CodingKeys: CodingKey { // case amount // } // // init(from decoder: Decoder) throws { // let container = try decoder.container(keyedBy: CodingKeys.self) // let doubleValue = try container.decode(Double.self, forKey: .amount) // amount = Decimal(doubleValue) // } } var value = Decimal(string: "0.00")! while value <= Decimal(string: "99.99")! { defer {value += Decimal(string: "0.01")!} let backendResponseText = """ {"amount": \(value)} """ let backendResponse = backendResponseText.data(using: .utf8)! print(backendResponseText) let decoded: DTO = try! JSONDecoder().decode(DTO.self, from: backendResponse)     debugPrint(decoded.amount, value == decoded.amount) } Result (Xcode 12.5.1) {"amount": 0} 0 true {"amount": 0.01} 0.01 true {"amount": 0.02} 0.02 true {"amount": 0.03} 0.03 true {"amount": 0.04} 0.04 true {"amount": 0.05} 0.05 true {"amount": 0.06} 0.06 true {"amount": 0.07} 0.07000000000000001024 false {"amount": 0.08} 0.08 true {"amount": 0.09} 0.09 true {"amount": 0.1} 0.1 true ... Result (Xcode 13) {"amount": 0} 0 true {"amount": 0.01} 0.01 true {"amount": 0.02} 0.02 true {"amount": 0.03} 0.03 true {"amount": 0.04} 0.04 true {"amount": 0.05} 0.05 true {"amount": 0.06} 0.06 true {"amount": 0.07} 0.07000000000000001024 false {"amount": 0.08} 0.08 true {"amount": 0.09} 0.09 true {"amount": 0.1} 0.1 true ... There are some differences in details, but it shows that JSONDecoder has some cases which cannot decode values to Decimal as expected in both Xcode 12.5.1 and Xcode 13.0 . You may need to choose a good workaround and test it with all possible values. Or avoid using JSON number and use JSON string to represent decimal values.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to Create an object inside a View from input parameters
I have tried several things and fixing one bug creates more bugs. You should have shown what you have tried if you really want help from readers. Taking time to write an answer and being said "I have already tried it but it does not work" is a depressing experience. Anyway, the right answer might depend on the parts you have not shown yet. You should better show more context to get better responses sooner. Anyway, this is one thing you should try first: struct MyView2: View { var url: URL private var myObject: SpecialObject @State private var progress: Float = Float() init(url: URL) { self.url = url self.myObject = SpecialObject(url: url) } let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() var body: some View { ProgressView("Downloading...", value: progress, total: 100).onReceive(timer) { _ in self.progress = self.myObject.get_progress() } } } (I renamed myView2 to MyView2. In Swift, type names should start with a Capital letter.) If this does not solve your issue, please do not say simply it does not work, but provide as much info as you can about the context and the code you have tried.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to I want to develop my first app
In summary, I wonder if the app can be developed as planned with the minimum hardware elements (purchase of insufficient machine or upgrade of system specifications) that go into making the three apps I envisioned. It took time to develop, but it would be sad if it was out of service support just before the goal, or if it violated Apple's policy. In my opinion, 2020 M1 MacBook Air (256 GB, 16 GB RAM) and an M1 iPad Pro 11 inch (8 GB RAM) would not be a super bad choice and it might be enough for developing a few, relatively simple apps. But you will soon feel that 256 GB is not enough and you may need to clean up your Mac very often. Anyway, start now, learning Apple's frameworks and programming languages might take far more time that you expect.
Oct ’21