Post

Replies

Boosts

Views

Activity

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 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 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 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 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 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 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 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
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 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 Make app available only for iPhone only not ipads
So for now we want to make our app available for iPhones only. Is there any way to do that? > NO. If you make your app for targeting iPhone only, your app needs to run on the simulator mode (3.5' screen) of iPad. Fix your app to run on iPad or make it target for both iPhone and iPad. The only other alternative is abandoning to publish it on the App Store.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Contacts Framework CNFetchResult
As the editing feature of this site is very limited, you may need to use Your Answer to add an additional info.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Is cocopod MMChatFramework still supported
@snafupatton, Seems you may need to find a better place to ask for good frameworks. The dev forums is for discussing about app development for Apple's platform using Apple's frameworks and Apple's tools. Many questions asking for third party frameworks had not gotten good responses here.
Replies
Boosts
Views
Activity
Dec ’21
Reply to NavigationLink issue
Can you share your code by showing it as text, not as image?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Publishig Failed
Can you be more specific? Please explain what you have done, what you have get and what you expect.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Is cocopod MMChatFramework still supported
Apple has never stated any of the pods as supported. You may need to contact to the author of the pod.
Replies
Boosts
Views
Activity
Dec ’21
Reply to UIDevice.current.orientation returns 0 when iPad is attached to external keyboard
Whether or not it would be an intended behavior, you can send a feedback if the current behavior does not fit for your app.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’21