Post

Replies

Boosts

Views

Activity

Reply to How to pass Regex object for use inside SwiftUI View
So I changed the type to Regex but I still get this error when trying to use my View: MyTextField(placeholder: "Phone Number", text: $phone, validation: /(0-9)*.{10}/) produces the error: Cannot convert value of type 'Regex<(Substring, Substring?)>' to expected argument type 'Regex' But then I did a simple test in a playground: let sub: Substring = "sub" let string: Substring? = "string" let substring = (sub, string) if let thing = substring as? Any {     print("WE HAVE THING: \(thing)") } Which warns me that Conditional cast from '(Substring, Substring?)' to 'Any' always succeeds So I'm a little confused how in the first example Regex<(Substring, Substring?)> can't be cast to Regex but (Substring, Substring?) can cast to Any in this example.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’23
Reply to How to pass Regex object for use inside SwiftUI View
So I changed the type to Regex but I still get this error when trying to use my View: MyTextField(placeholder: "Phone Number", text: $phone, validation: /(0-9)*.{10}/) produces the error: Cannot convert value of type 'Regex<(Substring, Substring?)>' to expected argument type 'Regex' But then I did a simple test in a playground: let sub: Substring = "sub" let string: Substring? = "string" let substring = (sub, string) if let thing = substring as? Any {     print("WE HAVE THING: \(thing)") } Which warns me that Conditional cast from '(Substring, Substring?)' to 'Any' always succeeds So I'm a little confused how in the first example Regex<(Substring, Substring?)> can't be cast to Regex but (Substring, Substring?) can cast to Any in this example.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23