Post

Replies

Boosts

Views

Activity

Reply to Variable for DestinationView
I would do it this way with ViewBuilder: struct ZodiacSign: Identifiable { let id = UUID() var name: String var symbol: String // as per Swift conventions, should start with lowercase // Replaced by ViewBuilder var DestinationView: View } @ViewBuilder func zodiacDestination(name: String) -> some View { switch name { case "Aries" : AriesView() case "Taurus" : TaurusView() case "Gemini" : GeminiView() case "Cancer" : CancerView() case "Leo" : LeoView() case "Virgo" : VirgoView() case "Libra" : LibraView() case "Scorpio" : ScorpioView() case "Sagittarius": SagittariusView() case "Capricorn": CapricornView() case "Aquarius" : AquariusView() case "Pisces" : PiscesView() default: EmptyView() } } struct ContentView: View { @State var starSigns = [ // Need to be a State var ZodiacSign(name: "Aries", symbol: "♈︎"), // DestinationView: AriesView()), ZodiacSign(name: "Taurus", symbol: "♉︎"), // DestinationView: TaurusView()), ZodiacSign(name: "Gemini", symbol: "♊︎"), // DestinationView: GeminiView()), ZodiacSign(name: "Cancer", symbol: "♋︎"), // DestinationView: CancerView()), ZodiacSign(name: "Leo", symbol: "♌︎"), // DestinationView: LeoView()), ZodiacSign(name: "Virgo", symbol: "♍︎"), // DestinationView: VirgoView()), ZodiacSign(name: "Libra", symbol: "♎︎"), // DestinationView: LibraView()), ZodiacSign(name: "Scorpio", symbol: "♏︎"), // DestinationView: ScorpioView()), ZodiacSign(name: "Sagittarius", symbol: "♐︎"), // DestinationView: SagittariusView()), ZodiacSign(name: "Capricorn", symbol: "♑︎"), // DestinationView: CapricornView()), ZodiacSign(name: "Aquarius", symbol: "♒︎"), // DestinationView: AquariusView()), ZodiacSign(name: "Pisces", symbol: "♓︎") // DestinationView: PiscesView()) ] var body: some View { // VStack { NavigationView { // You have to put in a NavigationView List { ForEach(starSigns, id: \.id) {zodiacSign in // should start with lowercase NavigationLink(destination: zodiacDestination(name: zodiacSign.name)) { Text(zodiacSign.symbol) Text(zodiacSign.name) } } } } } } struct AriesView: View { var body: some View { VStack { Text("♈︎ Aries is a constellation…") } } } struct TaurusView: View { var body: some View { VStack { Text("♉︎ Taurus is a constellation…") } } } struct GeminiView: View { var body: some View { VStack { Text("♊︎ Gemini is a constellation…") } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’24
Reply to Passing C++ Types as Reference using SWIFT_IMMORTAL_REFERENCE.
Just a remark on the use of the forum. You may ask as many questions as needed, but you have to answer to replies you get to tell if that answers your question (and then close the thread) or if not explain in the same post what is the remaining issue. Otherwise, developers on this forum may get tired to answer your repeated posts on very similar questions if they never receive a feedback. Have a good day.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’24
Reply to Variable for DestinationView
When you post code, please post more so that we can better explain the solution. So, show how stasSigns is defined and how each zodiacSign is defined in this structure. A typical pattern would be: struct ContentView : View { @ViewBuilder func destination(name: String) -> some View { switch name { case "aries": AriesView() // other case here default: EmptyView() } } var body: some View { List { ForEach(starSigns) {zodiacSign in // zodiacSign should start with lowercase, as it is an instance NavigationLink(destination: destination(name: zodiacSign.name)) {// destinationView should start with lowercase, as it is a property HStack { Text(zodiacSign.Symbol) Text(zodiacSign.name) } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’24
Reply to Testflight issue: "Could not install <app_name>. The requested app is not available or doesn't exist."
But when I archive the build and distribute it to TestFlight via AppStore Connect, I always get this error message as shown below. Did you get a reply from Appstore, such as this one: Dear raahimkhan, The following build has completed processing: Platform: iOS App Name: SomeRandomApplication Build Number: 1000 Version Number: 1.0.0 App SKU: yyyyyyyyyyyyy App Apple ID: xxxxxxxx You can now use this build for TestFlight testing or submit it for distribution. If you have any questions regarding your app, click Contact Us in App Store Connect. Regards, Apple Developer Relations If you have received, have you submitted to TestFlight ? How did you do it ?
Sep ’24
Reply to Is case sensitivity the default for any Mac?
Mac and it was case sensitive by default without them taking any action. What do you mean exactly by Mac is case sensitive ? Do you mean Finder ? Which version of MacOS ? What problem does this cause in your app ? On a Mac with 14.6.1 (23G93), if I have 2 files names : A File and A file, they are considered the same name (not case sensitive). But when sorting files by name, upper / lower case is taken into account.
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’24
Reply to Returning Reference from Swift Function
You seem to have a major concern with reference values. What is the main issue you have ? As a general comment, you should avoid trying to replicate exactly C++ patterns into Swift. Some logics (notably about types, memory management…) are pretty different and it may be risky with dangerous side effects. https://stackoverflow.com/questions/752658/is-the-practice-of-returning-a-c-reference-variable-evil In your example, what is the purpose of noexcept here ? Are you sure it is correct ? int & ReturnIntRef () It should be int& ReturnIntRef () Similar pattern in Swift would not work, as the var a would be deleted when exiting the function, unless you use an escaping closure, but that may be overkill. There are several ways to do what you want. A simple one, as I answered in another post is to call parameter as inout. you can also declare a class type that holds the parameter use pointers, at your own risks, as described in detail here: https://stackoverflow.com/questions/27539533/how-to-return-an-inout-reference-in-a-swift-function
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’24
Reply to Variable for DestinationView
I would do it this way with ViewBuilder: struct ZodiacSign: Identifiable { let id = UUID() var name: String var symbol: String // as per Swift conventions, should start with lowercase // Replaced by ViewBuilder var DestinationView: View } @ViewBuilder func zodiacDestination(name: String) -> some View { switch name { case "Aries" : AriesView() case "Taurus" : TaurusView() case "Gemini" : GeminiView() case "Cancer" : CancerView() case "Leo" : LeoView() case "Virgo" : VirgoView() case "Libra" : LibraView() case "Scorpio" : ScorpioView() case "Sagittarius": SagittariusView() case "Capricorn": CapricornView() case "Aquarius" : AquariusView() case "Pisces" : PiscesView() default: EmptyView() } } struct ContentView: View { @State var starSigns = [ // Need to be a State var ZodiacSign(name: "Aries", symbol: "♈︎"), // DestinationView: AriesView()), ZodiacSign(name: "Taurus", symbol: "♉︎"), // DestinationView: TaurusView()), ZodiacSign(name: "Gemini", symbol: "♊︎"), // DestinationView: GeminiView()), ZodiacSign(name: "Cancer", symbol: "♋︎"), // DestinationView: CancerView()), ZodiacSign(name: "Leo", symbol: "♌︎"), // DestinationView: LeoView()), ZodiacSign(name: "Virgo", symbol: "♍︎"), // DestinationView: VirgoView()), ZodiacSign(name: "Libra", symbol: "♎︎"), // DestinationView: LibraView()), ZodiacSign(name: "Scorpio", symbol: "♏︎"), // DestinationView: ScorpioView()), ZodiacSign(name: "Sagittarius", symbol: "♐︎"), // DestinationView: SagittariusView()), ZodiacSign(name: "Capricorn", symbol: "♑︎"), // DestinationView: CapricornView()), ZodiacSign(name: "Aquarius", symbol: "♒︎"), // DestinationView: AquariusView()), ZodiacSign(name: "Pisces", symbol: "♓︎") // DestinationView: PiscesView()) ] var body: some View { // VStack { NavigationView { // You have to put in a NavigationView List { ForEach(starSigns, id: \.id) {zodiacSign in // should start with lowercase NavigationLink(destination: zodiacDestination(name: zodiacSign.name)) { Text(zodiacSign.symbol) Text(zodiacSign.name) } } } } } } struct AriesView: View { var body: some View { VStack { Text("♈︎ Aries is a constellation…") } } } struct TaurusView: View { var body: some View { VStack { Text("♉︎ Taurus is a constellation…") } } } struct GeminiView: View { var body: some View { VStack { Text("♊︎ Gemini is a constellation…") } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Passing C++ Types as Reference using SWIFT_IMMORTAL_REFERENCE.
Just a remark on the use of the forum. You may ask as many questions as needed, but you have to answer to replies you get to tell if that answers your question (and then close the thread) or if not explain in the same post what is the remaining issue. Otherwise, developers on this forum may get tired to answer your repeated posts on very similar questions if they never receive a feedback. Have a good day.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Variable for DestinationView
When you post code, please post more so that we can better explain the solution. So, show how stasSigns is defined and how each zodiacSign is defined in this structure. A typical pattern would be: struct ContentView : View { @ViewBuilder func destination(name: String) -> some View { switch name { case "aries": AriesView() // other case here default: EmptyView() } } var body: some View { List { ForEach(starSigns) {zodiacSign in // zodiacSign should start with lowercase, as it is an instance NavigationLink(destination: destination(name: zodiacSign.name)) {// destinationView should start with lowercase, as it is a property HStack { Text(zodiacSign.Symbol) Text(zodiacSign.name) } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Testflight issue: "Could not install <app_name>. The requested app is not available or doesn't exist."
But when I archive the build and distribute it to TestFlight via AppStore Connect, I always get this error message as shown below. Did you get a reply from Appstore, such as this one: Dear raahimkhan, The following build has completed processing: Platform: iOS App Name: SomeRandomApplication Build Number: 1000 Version Number: 1.0.0 App SKU: yyyyyyyyyyyyy App Apple ID: xxxxxxxx You can now use this build for TestFlight testing or submit it for distribution. If you have any questions regarding your app, click Contact Us in App Store Connect. Regards, Apple Developer Relations If you have received, have you submitted to TestFlight ? How did you do it ?
Replies
Boosts
Views
Activity
Sep ’24
Reply to Is case sensitivity the default for any Mac?
Mac and it was case sensitive by default without them taking any action. What do you mean exactly by Mac is case sensitive ? Do you mean Finder ? Which version of MacOS ? What problem does this cause in your app ? On a Mac with 14.6.1 (23G93), if I have 2 files names : A File and A file, they are considered the same name (not case sensitive). But when sorting files by name, upper / lower case is taken into account.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Returning Reference from Swift Function
You seem to have a major concern with reference values. What is the main issue you have ? As a general comment, you should avoid trying to replicate exactly C++ patterns into Swift. Some logics (notably about types, memory management…) are pretty different and it may be risky with dangerous side effects. https://stackoverflow.com/questions/752658/is-the-practice-of-returning-a-c-reference-variable-evil In your example, what is the purpose of noexcept here ? Are you sure it is correct ? int & ReturnIntRef () It should be int& ReturnIntRef () Similar pattern in Swift would not work, as the var a would be deleted when exiting the function, unless you use an escaping closure, but that may be overkill. There are several ways to do what you want. A simple one, as I answered in another post is to call parameter as inout. you can also declare a class type that holds the parameter use pointers, at your own risks, as described in detail here: https://stackoverflow.com/questions/27539533/how-to-return-an-inout-reference-in-a-swift-function
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’24