Post

Replies

Boosts

Views

Activity

Reply to NavigationStack Fatal error: ‘try!
Your first item in the Picker is Text("Select a Handle") and you've set the tag to nil. So, if someone picks the first item then the selectedHandle is going to be nil. That cannot be stored in roundsdata.roundsHandle, because you've said it's 'text' (I'm sure you meant String). So, just don't update roundsdata.roundsHandle in onChange when it's nil, i.e.: .onChange(of: selectedHandle) { if(selectedHandle != nil) { roundsdata.roundsHandle = selectedHandle } } Next, your players in the ForEach have a player value that you're setting the tag to, so when someone picks something other than the first item (which is nil) it will attempt to set roundsdata.roundsHandle to that value, but your tag is player as PlayerData?. That means you're trying to set roundsdata.roundsHandle to an Optional(PlayerData). That's why you're getting the error. You need to set the tag to a String value from the player, not to a PlayerData object. You have Text(player.playerHandle) so the player.playerHandle is a String. I think that's what you need to set the tag to, i.e.: Picker("Handle:", selection: $selectedHandle) { Text("Select a Handle").tag(nil) ForEach(players, id: \.self) { player in Text(player.playerHandle) .tag(player.playerHandle) } } .onChange(of: selectedHandle) { if(selectedHandle != nil) { roundsdata.roundsHandle = selectedHandle } } It looks like you don't completely understand how these pickers work because you're over-complicating it. This might help: Picker("Select something", selection: $thisIsPopulatedWithTheThingSelected) { // List the things we want in the picker, like days of the week ForEach(myArrayOfDayStrings, id: \.self) { day in Text(day) // Shows Monday-Sunday .tag(day) // For Monday, the tag is Monday. For Tuesday, it's Tuesday etc. // When someone picks Monday, $thisIsPopulatedWithTheThingSelected becomes Monday. Pick Tuesday and it's Tuesday. } } .onChange(of: thisIsPopulatedWithTheThingSelected) { print("You picked \(thisIsPopulatedWithTheThingSelected)") }
Topic: Design SubTopic: General
Nov ’24
Reply to NavigationStack Fatal error: ‘try!
I don't want to labour the point, but once you make a post that has code in it you need to look at that post and see whether you've put the backticks in the right place: Anyway, have you tried adding an .onChange(of:) {} to the DatePicker to print out the value of the variable? If it's being set correctly, you can then just manually set your value, i.e.: DatePicker("Date:", selection: $playDate, displayedComponents: [.date]) .onChange(of: playDate) { roundsdata.roundsDate = playDate } The same applies for your Picker, but make sure you add the .onChange(of:) {} to the closing brace for the Picker and not on anything inside it, like the Text and ForEach items.
Topic: Design SubTopic: General
Nov ’24
Reply to Photo App on IOS18
Thanks for your comments, however this is the wrong place for them. These are the Developer Forums, where developers of third-party apps for Apple's platforms ask each other for hints and tips on coding. These forums are not where Apple's actual employee developers chat about what they're doing in the platform code. If you have a suggestion, you should raise it at: https://www.apple.com/feedback/. Thanks.
Nov ’24
Reply to exit(0)
No. This is a terrible user experience. You should display a modal view that takes over the entire screen, and cannot be dismissed, that explains why the app cannot function. That's it. You don't need to give the user a button to kill the app. It's unnecessary and a horrible experience.
Nov ’24
Reply to NavigationStack Fatal error: ‘try!
It's quite clear that your code formatting didn't work properly when you posted this, so you should've immediately revised it and corrected it. Basically, put three backticks on one line, then all of your code, then another line with just three backticks on it. It's not difficult, and it would help us when reading it. You've put a bunch of commented code in there. Is it relevant to your issue? You don't say what line causes the error? Why does this need to be embedded in a NavigationStack anyway? Why do you need an HStack around one DatePicker? At your ForEach(players, id: \.self) { player in line, you have an HStack and a Text with some modifiers (.frame and .tag). Why have you put this in an HStack and then put the same modifiers on the HStack? Are the five HStacks at the bottom relevant to the issue? I'm not entirely sure you understand how HStacks work. They place items horizontally. If there's only one item, does it need to be in an HStack? Please clean up this question and we may be able to help you. In doing so you might actually fix the issue yourself...
Topic: Design SubTopic: General
Nov ’24
Reply to I get this Issue : ContentView.swift:3016:25 The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions. But I don´t know what I have to do. I am a noob. Can anybody help me.
You just need to apply the right filters. You have this function: func filteredItems(for category: MenuCategory) -> [MenuItem] { return sampleMenuItems.filter { $0.category == category } } It filters the sampleMenuItems and returns only those items that match the category. This line: let filteredItems = sampleMenuItems.filter in your ForEach... is pointless and is likely causing your issue. This: ForEach(filteredItems) { item in } has nothing in it. Also, it's a code smell. You've got a variable called filteredItems AND a function with the same name. Don't do this. This: MenuItemRow(item: sampleMenuItems.filter) { addItemToOrder } Again, the sampleMenuItems.filter bit is incorrect.
Nov ’24
Reply to Emoji Keyboard size is large after updating to iOS 18.1
These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Your question is more of a product support one, so I'd suggest you ask it over at the Apple Support Forums. Thanks.
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to why does tripple camera take photo faster than single camera device?
These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Your question is more of a product support one, so I'd suggest you ask it over at the Apple Support Forums. Thanks.
Replies
Boosts
Views
Activity
Dec ’24
Reply to ICloud issue on iphone 12 after upgrading to iOs18.1.1
These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Your question is more of a product support one, so I'd suggest you ask it over at the Apple Support Forums. Thanks.
Replies
Boosts
Views
Activity
Nov ’24
Reply to Network issue
Word salad. You're not making sense.
Replies
Boosts
Views
Activity
Nov ’24
Reply to Re-released product marked as 'spam'
Please don't post duplicates. If you need to update a post, just edit it.
Replies
Boosts
Views
Activity
Nov ’24
Reply to NavigationStack Fatal error: ‘try!
.onChange has not been deprecated. It has changed. I've given you the current non-deprecated version.
Topic: Design SubTopic: General
Replies
Boosts
Views
Activity
Nov ’24
Reply to NavigationStack Fatal error: ‘try!
Your first item in the Picker is Text("Select a Handle") and you've set the tag to nil. So, if someone picks the first item then the selectedHandle is going to be nil. That cannot be stored in roundsdata.roundsHandle, because you've said it's 'text' (I'm sure you meant String). So, just don't update roundsdata.roundsHandle in onChange when it's nil, i.e.: .onChange(of: selectedHandle) { if(selectedHandle != nil) { roundsdata.roundsHandle = selectedHandle } } Next, your players in the ForEach have a player value that you're setting the tag to, so when someone picks something other than the first item (which is nil) it will attempt to set roundsdata.roundsHandle to that value, but your tag is player as PlayerData?. That means you're trying to set roundsdata.roundsHandle to an Optional(PlayerData). That's why you're getting the error. You need to set the tag to a String value from the player, not to a PlayerData object. You have Text(player.playerHandle) so the player.playerHandle is a String. I think that's what you need to set the tag to, i.e.: Picker("Handle:", selection: $selectedHandle) { Text("Select a Handle").tag(nil) ForEach(players, id: \.self) { player in Text(player.playerHandle) .tag(player.playerHandle) } } .onChange(of: selectedHandle) { if(selectedHandle != nil) { roundsdata.roundsHandle = selectedHandle } } It looks like you don't completely understand how these pickers work because you're over-complicating it. This might help: Picker("Select something", selection: $thisIsPopulatedWithTheThingSelected) { // List the things we want in the picker, like days of the week ForEach(myArrayOfDayStrings, id: \.self) { day in Text(day) // Shows Monday-Sunday .tag(day) // For Monday, the tag is Monday. For Tuesday, it's Tuesday etc. // When someone picks Monday, $thisIsPopulatedWithTheThingSelected becomes Monday. Pick Tuesday and it's Tuesday. } } .onChange(of: thisIsPopulatedWithTheThingSelected) { print("You picked \(thisIsPopulatedWithTheThingSelected)") }
Topic: Design SubTopic: General
Replies
Boosts
Views
Activity
Nov ’24
Reply to NavigationStack Fatal error: ‘try!
I don't want to labour the point, but once you make a post that has code in it you need to look at that post and see whether you've put the backticks in the right place: Anyway, have you tried adding an .onChange(of:) {} to the DatePicker to print out the value of the variable? If it's being set correctly, you can then just manually set your value, i.e.: DatePicker("Date:", selection: $playDate, displayedComponents: [.date]) .onChange(of: playDate) { roundsdata.roundsDate = playDate } The same applies for your Picker, but make sure you add the .onChange(of:) {} to the closing brace for the Picker and not on anything inside it, like the Text and ForEach items.
Topic: Design SubTopic: General
Replies
Boosts
Views
Activity
Nov ’24
Reply to My iOS app that I created since 2011, crashes on M4 machine (M1 is fine!)
Is this your code FincancialCoreFrameWork? I ask because "Financial" is spelled incorrectly, and "Framework" is one word not two, so doesn't need the W to be capitalised. It looks like some error accessing a file? Can you put in some error handling around that? Also, are you sure this only happens on an M4 Mac? What version of macOS?
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Nov ’24
Reply to Photo App on IOS18
Thanks for your comments, however this is the wrong place for them. These are the Developer Forums, where developers of third-party apps for Apple's platforms ask each other for hints and tips on coding. These forums are not where Apple's actual employee developers chat about what they're doing in the platform code. If you have a suggestion, you should raise it at: https://www.apple.com/feedback/. Thanks.
Replies
Boosts
Views
Activity
Nov ’24
Reply to exit(0)
No. This is a terrible user experience. You should display a modal view that takes over the entire screen, and cannot be dismissed, that explains why the app cannot function. That's it. You don't need to give the user a button to kill the app. It's unnecessary and a horrible experience.
Replies
Boosts
Views
Activity
Nov ’24
Reply to NavigationStack Fatal error: ‘try!
It's quite clear that your code formatting didn't work properly when you posted this, so you should've immediately revised it and corrected it. Basically, put three backticks on one line, then all of your code, then another line with just three backticks on it. It's not difficult, and it would help us when reading it. You've put a bunch of commented code in there. Is it relevant to your issue? You don't say what line causes the error? Why does this need to be embedded in a NavigationStack anyway? Why do you need an HStack around one DatePicker? At your ForEach(players, id: \.self) { player in line, you have an HStack and a Text with some modifiers (.frame and .tag). Why have you put this in an HStack and then put the same modifiers on the HStack? Are the five HStacks at the bottom relevant to the issue? I'm not entirely sure you understand how HStacks work. They place items horizontally. If there's only one item, does it need to be in an HStack? Please clean up this question and we may be able to help you. In doing so you might actually fix the issue yourself...
Topic: Design SubTopic: General
Replies
Boosts
Views
Activity
Nov ’24
Reply to 16 pro max keeps restarting on its own
These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Your question is more of a product support one, so I'd suggest you ask it over at the Apple Support Forums. Thanks.
Replies
Boosts
Views
Activity
Nov ’24
Reply to I get this Issue : ContentView.swift:3016:25 The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions. But I don´t know what I have to do. I am a noob. Can anybody help me.
You just need to apply the right filters. You have this function: func filteredItems(for category: MenuCategory) -> [MenuItem] { return sampleMenuItems.filter { $0.category == category } } It filters the sampleMenuItems and returns only those items that match the category. This line: let filteredItems = sampleMenuItems.filter in your ForEach... is pointless and is likely causing your issue. This: ForEach(filteredItems) { item in } has nothing in it. Also, it's a code smell. You've got a variable called filteredItems AND a function with the same name. Don't do this. This: MenuItemRow(item: sampleMenuItems.filter) { addItemToOrder } Again, the sampleMenuItems.filter bit is incorrect.
Replies
Boosts
Views
Activity
Nov ’24
Reply to Nomor Call Center Tunaiku WhatsApp 082280802022
Hey, App Store Connect Engineer, this is clearly spam. Mark it as such and remove it.
Replies
Boosts
Views
Activity
Nov ’24