Post

Replies

Boosts

Views

Activity

Reply to Xcode
Xcode 13 has changed many things, how to handle Info.plist, storyboard format, project templates and so on. You may need to find a good tutorial about what's new in Xcode 13 or get an older version of Xcode.
Dec ’21
Reply to Referencing initializer 'init(_:content:)' on 'ForEach' requires that 'Image' conform to 'Identifiable'
As you can find in the error message, each element passed to ForEach needs to conform to Identifiable (or easily provide id to identify). You should better think Image is not a good thing to hold in an Array and use with ForEach. One possible solutions would be holding UIImage (or CGImage) in an Array: Something like this: struct FilterView: View{ @State var image: Image? let filteredUIImage: [UIImage] //<- var body: some View { NavigationView{ ZStack{ //... VStack { //... ScrollView(.horizontal, showsIndicators: false) { HStack{ ForEach(filteredUIImage, id: \.self) { uiImage in //<- //... } } } } } } .toolbar { //... } } //... } And creating a local variable holding a view does not make sense. You need to update your loadFilter(): struct ContentView: View { //... @State var filteredUIImage: [UIImage] = [] //<- //... var body: some View { //... .navigate(to: FilterView(image: image, filteredUIImage: filteredUIImage), when: $showingFilterView) //<- } //... func loadFilter() { filteredUIImage = [] filters.forEach { (filters) in //... let uiImage = UIImage(cgImage: cgimg!) //let filteredImage = Image(uiImage: uiImage) //Creating a view as local variable does not make sense // let filterView = FilterView() // filterView.filteredImage.append(filteredImage) filteredUIImage.append(uiImage) } } } I'm not sure if this is the best solution for your purpose, generally having many images in an array would not be recommended.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’21
Reply to Using Combine-Future to Fetch Server Data
What am I doing wrong?  In your code, you are making viewModel a local variable, so it will be released just after print("Yeah..."). Please try something like this: class ViewController: UIViewController { // MARK: - Variables private var cancellableSet: Set<AnyCancellable> = [] var viewModel: ViewModel! //<- // MARK: - Life cycle override func viewDidLoad() { super.viewDidLoad() let urlStr = "https://api.github.com/repos/ReactiveX/RxSwift/events" viewModel = ViewModel(urlStr: urlStr, waitTime: 2.0) //<- No `let` here` viewModel.fetchData(urlText: viewModel.urlStr, timeInterval: viewModel.waitTime) .sink { completion in print("complete") } receiveValue: { dataSet in print("count: \(dataSet)") } .store(in: &cancellableSet) print("Yeah...") } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Dec ’21
Reply to Playground 4 App doesn’t have code snippets?
Seems you are right and I cannot find a code snippet icon { } tapping +. (iPad mini 6) I guess Apple's designers of Swift Playgrounds have chosen some more specific set of code snippets for App project, rather than basic code snippets found in Playgrounds projects. Maybe they might be expecting that the users of App projects would be more experienced than users of Playground projects. You may send a feature request using the Feedback Assistant.
Dec ’21
Reply to Where is Playgrounds 4? It's 2021-12-14 now...
The Release Notes of Xcode 13.2 contains the statement Xcode 13.2 includes support for app projects you create with Swift Playgrounds 4. I do expect it will not be too far.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Xcode
Xcode 13 has changed many things, how to handle Info.plist, storyboard format, project templates and so on. You may need to find a good tutorial about what's new in Xcode 13 or get an older version of Xcode.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Referencing initializer 'init(_:content:)' on 'ForEach' requires that 'Image' conform to 'Identifiable'
As you can find in the error message, each element passed to ForEach needs to conform to Identifiable (or easily provide id to identify). You should better think Image is not a good thing to hold in an Array and use with ForEach. One possible solutions would be holding UIImage (or CGImage) in an Array: Something like this: struct FilterView: View{ @State var image: Image? let filteredUIImage: [UIImage] //<- var body: some View { NavigationView{ ZStack{ //... VStack { //... ScrollView(.horizontal, showsIndicators: false) { HStack{ ForEach(filteredUIImage, id: \.self) { uiImage in //<- //... } } } } } } .toolbar { //... } } //... } And creating a local variable holding a view does not make sense. You need to update your loadFilter(): struct ContentView: View { //... @State var filteredUIImage: [UIImage] = [] //<- //... var body: some View { //... .navigate(to: FilterView(image: image, filteredUIImage: filteredUIImage), when: $showingFilterView) //<- } //... func loadFilter() { filteredUIImage = [] filters.forEach { (filters) in //... let uiImage = UIImage(cgImage: cgimg!) //let filteredImage = Image(uiImage: uiImage) //Creating a view as local variable does not make sense // let filterView = FilterView() // filterView.filteredImage.append(filteredImage) filteredUIImage.append(uiImage) } } } I'm not sure if this is the best solution for your purpose, generally having many images in an array would not be recommended.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Xcode Crashes While I Am doing SwiftUI Tutorial
Have you checked all the parts of your code containing longtitude? That should be longitude, I think.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to app crashes on test "exception" type":"EXC_CRASH","signal":"SIGABRT"},
Unfortunately, that part does not contain any significant info to solve the issue. Can you share the whole crash log?
Replies
Boosts
Views
Activity
Dec ’21
Reply to NavigationLink init(_:destination:) deprecated
I tried your code with Xcode 12.5.1 and it shows the same error. And trying with Xcode 13.1, it compiles without any problems. I'm not sure what is causing this issue, but until the problem is solved, you may need to use Xcode 13.x .
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to How to load data from a structure when opening a view
The tag wwdc21-10002 is not relevant for your question. Using the right tag would help you getting the right answers sooner. Also important is showing enough code. Can you show enough code to reproduce your issue?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to What is wrong with my code ?
What is the expected result of your code? What is the actual result you get? For which platform is your app? Can you show your code properly formatted? Is your question really relevant to wwdc21-10002?
Replies
Boosts
Views
Activity
Dec ’21
Reply to Using Combine-Future to Fetch Server Data
What am I doing wrong?  In your code, you are making viewModel a local variable, so it will be released just after print("Yeah..."). Please try something like this: class ViewController: UIViewController { // MARK: - Variables private var cancellableSet: Set<AnyCancellable> = [] var viewModel: ViewModel! //<- // MARK: - Life cycle override func viewDidLoad() { super.viewDidLoad() let urlStr = "https://api.github.com/repos/ReactiveX/RxSwift/events" viewModel = ViewModel(urlStr: urlStr, waitTime: 2.0) //<- No `let` here` viewModel.fetchData(urlText: viewModel.urlStr, timeInterval: viewModel.waitTime) .sink { completion in print("complete") } receiveValue: { dataSet in print("count: \(dataSet)") } .store(in: &cancellableSet) print("Yeah...") } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Playground 4 App doesn’t have code snippets?
Seems you are right and I cannot find a code snippet icon { } tapping +. (iPad mini 6) I guess Apple's designers of Swift Playgrounds have chosen some more specific set of code snippets for App project, rather than basic code snippets found in Playgrounds projects. Maybe they might be expecting that the users of App projects would be more experienced than users of Playground projects. You may send a feature request using the Feedback Assistant.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Create a line break in a ForEach
Can you share your code? It would be much better if the code contains some example data.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to 60gb space gone after Xcode update
So what?
Replies
Boosts
Views
Activity
Dec ’21
Reply to Write, Create and Read Excel Files in Swift without using third party library
No such functionalities in Apple's frameworks. Visit Microsoft's site which explains the data format of Excel and do all by yourself (maybe some work of years), or find a third party library.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to UITextFiled.selectedTextRange bug on iOS 15
Sharing some info about iOS bugs is not a bad thing, but the right place to report bugs is the Feedback Assistant. Have you already sent a bug report?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to DateEncodingStrategy.custom encoder is immutable type?
(Duplicate answer removed)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’21