Post

Replies

Boosts

Views

Activity

Reply to Callback Function As Parameter
Even better, you can use the concise and stylish trailing closure syntax: temp(type: "Here") { print("hey") } Also, consider keeping the callback argument label. With trailing closure syntax you don’t use it anyway, and it improves clarity if you pass a method or function name instead of a literal closure block, like this: temp(type: "Here", callback: methodOrFunctionThatPrintsHey)
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’23
Reply to WeatherKit REST API
Are you Remember that this forum is a community of developers, not an official communication channel to Apple. going to [do something] in the future [...]? Nobody on this forum can answer questions like that. Your best bet is to file a Feedback with your requested enhancement.
Topic: App & System Services SubTopic: General Tags:
Feb ’23
Reply to Database error when testing on device
let fileURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appendingPathComponent("TurMer.sqlite”) Once this line is executed, it tells me that everything is correct. Not quite correct. That line returns a URL for where that file would be located (within your Documents directory) whether it exists or not. It doesn’t check if that a file actually exists at that location. In this case, no such file exists. When your app first starts, the Documents directory is empty. See @eskimo’s reply above for finding your database file within your app bundle, which is totally separate from the Documents directory. if sqlite3_open(fileURL.path, &BaseDatos) != SQLITE_OK In this line we have opened the database. Everything is correct, it tells me that the database exists Not quite. Note the documentation for sqlite3_open says that the database will be created if it doesn’t already exist. So this actually creates and opens an empty database. That’s why the subsequent query fails. In general, don’t use sqlite3_open in new code. You should switch to sqlite3_open_v2 which gives you better control over its behavior. Use the flag SQLITE_OPEN_READONLY (since you said earlier that your database is read-only) or use SQLITE_OPEN_READWRITE if desired. This will cause sqlite3_open_v2 to fail if the file doesn’t already exist, which would have alerted you to the problem earlier.
Feb ’23
Reply to Database error when testing on device
And remember that your bundle is read-only so, as Scott suggested, you want to open it with SQLITE_OPEN_READONLY. One more thing I just remembered (from doing this years ago)... you may also need to do this when you call sqlite3_open_v2: add the SQLITE_OPEN_URI flag pass the path as a file: URI rather than a raw path append query parameter ?immutable=1 to that URI This makes SQLite work correctly when the file is on a read-only disk, which is basically what your app bundle is. See these pages for more detail: https://www.sqlite.org/c3ref/open.html https://www.sqlite.org/uri.html#coreqp
Feb ’23
Reply to Getting all running process and memory usage of downloaded apps
Apps like that aren’t really a thing on iOS. You may find them on other mobile platforms, but not here. Consider this: such a tool would be useful only if you could get the name of each process executable (rather than, say, just a process ID). And getting that information would be a massive privacy fail. Your app would be able to infer (and make fingerprints of, and sell to advertisers) a list of what other apps the user has installed on their device. That sort of abuse is most definitely not supported by any API on this platform. BTW, check out On Free Memory for discussion of why even aggregated memory information isn’t as useful as it sounds.
Mar ’23
Reply to Is a closure enum associated value escaping?
You should consider the closure to be escaping. The syntax for declaring an enum associated value isn’t quite the same as an initializer so there’s nowhere to put the @escaping keyword, but the effect is the same: the closure is retained by the enum value and may be called later. If you do this in a class context and implicitly reference self then you’ll get the familiar warning about that: class Foo: NSObject { func foo() {         _ = Operation.opA {             print(description) // ERROR: Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit         }     } }
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’23