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 } }
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