Post

Replies

Boosts

Views

Activity

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 How to make an updatable ForEach loop SwiftUI
When I start the app there's only one "hey" and no more will show up when I add more flags. No, you get 2 heys, as explained by @B347 What you want is not clear at all. what do you expect to get ? display text per child: where are the children defined ? where and how do you add flags ? In any case, if you want view to be updated, flags should be a State var. An advice: study an Apple tutorial on Swift and SwiftUI. It seems there are some basics you are still missing.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’24
Reply to Inserting array of model objects using modelContext
AFAIK, there is not. But it is really easy to build it (even as extension) by calling insert in a loop on all objects. Get some additional advice here for performance optimisation: https://stackoverflow.com/questions/77533881/how-do-you-insert-an-array-of-objects-into-the-swiftdata-modelcontext modelContext.transaction { for obj in objects { modelContext.insert(obj) } do { try modelContext.save() } catch { // Handle error } }
Topic: App & System Services SubTopic: iCloud Tags:
Sep ’24
Reply to Copy Creation when we pass primitive type such as Int to a Swift Function.
If you want to pass a reference, to be able to modify the parameter, you have to use inout. public func Test (_ pValue : inout Int) { print ("on call", pValue) pValue += 10 } var x : Int = 2 // Must be a var ; // with let, would get a compile error: // Cannot pass immutable value as inout argument: 'x' is a 'let' constant Test (&x) print ("after call", x) You get: on call 2 after call 12
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’24
Reply to iPhone 16, Plus, Pro and Pro Max device identifiers/codes?
That seems a reasonable assumption, but just assumption. I wait for the list to be updated here: https://gist.github.com/adamawolf/3048717 Here is what they say, which is slightly different from you: "iPhone17,3": .iPhone16, "iPhone17,4": .iPhone16Plus, "iPhone17,1": .iPhone16Pro, "iPhone17,2": .iPhone16ProMax,
Topic: App & System Services SubTopic: Hardware Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Returning Typed Pointer From Swift to C++
Yes, UnsafeMutableRawPointer is a way to do it. But look at some other of your post for a discussion about the issues doing so.
Topic: Programming Languages SubTopic: Swift Tags:
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
Reply to How to make an updatable ForEach loop SwiftUI
Thanks, but that's not enough to test code. We don't see var declarations, code to change the flags… So, no way to help with so limited code.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to How to make an updatable ForEach loop SwiftUI
Thanks for the reply. What is needed is to see the complete code, to understand what you do and what is to be changed.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to How to make an updatable ForEach loop SwiftUI
When I start the app there's only one "hey" and no more will show up when I add more flags. No, you get 2 heys, as explained by @B347 What you want is not clear at all. what do you expect to get ? display text per child: where are the children defined ? where and how do you add flags ? In any case, if you want view to be updated, flags should be a State var. An advice: study an Apple tutorial on Swift and SwiftUI. It seems there are some basics you are still missing.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Inserting array of model objects using modelContext
AFAIK, there is not. But it is really easy to build it (even as extension) by calling insert in a loop on all objects. Get some additional advice here for performance optimisation: https://stackoverflow.com/questions/77533881/how-do-you-insert-an-array-of-objects-into-the-swiftdata-modelcontext modelContext.transaction { for obj in objects { modelContext.insert(obj) } do { try modelContext.save() } catch { // Handle error } }
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Copy Creation when we pass primitive type such as Int to a Swift Function.
If you want to pass a reference, to be able to modify the parameter, you have to use inout. public func Test (_ pValue : inout Int) { print ("on call", pValue) pValue += 10 } var x : Int = 2 // Must be a var ; // with let, would get a compile error: // Cannot pass immutable value as inout argument: 'x' is a 'let' constant Test (&x) print ("after call", x) You get: on call 2 after call 12
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to how can xcode burn energy??
You complain but you do not explain what is your problem or your need, what you've tried that does not work. So please, formulate your question in a way we can understand.
Replies
Boosts
Views
Activity
Sep ’24
Reply to Passing Structure Initiated in Swift To C++ Function as In Param.
You have several questions about Swift / C++ integration. Did you read this "Mixing Swift and C++ Using Xcode": https://www.swift.org/documentation/cxx-interop/project-build-setup/
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to How can you make a TextField update text with SwiftData / CloudKit?
Just I idea, I did not test. Try with onReceive modifier instead of onChange.
Replies
Boosts
Views
Activity
Sep ’24
Reply to Customising TabView styling
I wanted to test your code, but it does not compile. Is it the complete real code ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Xcode 16 Beta Swift Compiler Settings Missing
Here is what I get (for an old project), in Xcode 16.1ß1 What you have in User Defined is in the general section for me. And no reference to beta version. Did you try creating a new project to see what you get ?
Replies
Boosts
Views
Activity
Sep ’24
Reply to Release version of App crashes on launch
Have a look at this other thread: https://forums.developer.apple.com/forums/thread/761374
Replies
Boosts
Views
Activity
Sep ’24