Post

Replies

Boosts

Views

Activity

Reply to Bundling app with our own SQLite
Can we bundle our app with our own version of SQLite with extensions that we want. Yes, and you should do that. The version that Apple includes depends on the iOS version (see https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS) for a table). If you use the Apple version, there's a danger that your app will break after an iOS update, or will not function on an older iOS version that you are still trying to support but don't test on as well as you should. I was caught out by the latter issue because the sqlite in iOS 14 doesn't support "on conflict" without a column list.
Aug ’25
Reply to How can I calculate distance and vertical velocity?
Sure, you can integrate acceleration to get velocity and integrate velocity to get distance. But the problem is that you integrate all the errors in the sensor values too, and they quickly dominate. This is a well-known problem that has been studied in the context of submarine, aircraft and spacecraft navigation (pre-GPS) for decades. The solutions tend to be either ever-more precise sensors (which is not something you can change on a phone) and "sensor fusion", where you blend your integrated value with a value from another sensor. One example of sensor fusion is the Kalman Filter - look it up. Do be aware that the sensor values that you get on iOS have probably already been processed in some way by the system before you receive them.
Topic: App & System Services SubTopic: General Tags:
Aug ’25
Reply to CGColorRef is NOT a struct
Now, returning to the Objective-C doc, I see this: What you're seeing now is the fixed version. Until yesterday, the * was missing. AgentFriday and I both understand the differences between classes and structs in C, objC and Swift and neither of us was misreading anything. There was no confusion; it was a bug in the documentation generator which has now finally been fixed. user-level bug Huh? There's a difference between "user-level bugs" and "developer-level bugs"? I guess I'd better go and look at all my completely ignored bug reports from the last decades and check if any of them accidentally got in a "user-level" category.
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’25
Reply to Install HTTP Live Streaming Tools on Linux ARM
is there a way to run them like Mac OS does with Rosseta? Yes, you can use qemu. If you apt-get install qemu-user qemu-user-binfmt then invoking an x86 executable will use qemu to run it. But there’s a snag - if the executable is dynamically linked, you also need the x86 versions of the libraries that it is linked with. On Debian, this is achieved using ”multiarch”. Of course the performance may not be great! If I were you, I’d work out how to do it using ffmpeg. It’s not fundamentally difficult, though it is somewhat tedious to find all the right incantations.
Topic: Media Technologies SubTopic: Streaming Tags:
Apr ’25
Reply to XCode not making bridging header file?
There are two distinct things here: You can export C or C++ (hmmm objC?) to Swift. You can export Swift to C/C++/ObjC. It looks like you want to do the latter. For that, XCode does generate a header but it’s not the file you are looking at in your source tree. It’s a temporary file deep inside the build / intermediates folder structure. The file you are looking at is for exporting in the other direction - as the comment you quoted says - and you can ignore it. Hopefully that is enough to get you a bit further. You may find previous discussions here if you search for e.g. “bridging”.
Apr ’25
Reply to Unable to use altitude for our use case (NYC MTA)
These levels typically differ by at least 15 feet, which should in theory be well within the precision range of a properly calibrated barometric pressure sensor. Yes, but… However, the absolute altitude values we’re seeing from these APIs are often inaccurate and inconsistent … Apple have ”improved“ them for you. If I were you, I’d look at the raw(?) barometric pressure that should be in CMAltitudeData.pressure. See if this is consistent between devices, and has the resolution that you need to determine station levels. If it does, you just need to know current local sea level pressure. You can probably assume that is constant across your area of interest. Have your app get that from your servers every hour, or whatever. (Out of interest, are the barometric pressures in underground stations affected by the piston effect of the moving trains enough to perturb this analysis?)
Apr ’25
Reply to Class not being called?
please could you explain why does creating the instance of API not work as a global Maybe it does work. You don’t see your “line 25” because you didn’t call resume() and the download never happened. Maybe the object was constructed, we don’t know. The point is that it shouldn‘t be a global because that’s a bad design, not because it won’t work.
Mar ’25
Reply to Why does Array's contains(_:) method cause an error when comparing an optional value with a non-optional value in Swift?
Why does the first example work I don’t know. but the second one fails with a compile-time error? What exactly causes this error in the second case, even though both cases involve comparing an optional value with a non-optional value? The declaration of contains that you posted shows that it takes an Element. Element is String. If you don’t pass a String, you’ll get an error. (The fact that it calls another contains method that would work with the optional doesn’t matter; it doesn’t get that far. You could argue that contains should not take an Element but rather an equality-comparable-with-Element; I think that’s possible.) Does contains(_:) behave differently when used with an explicit array variable rather than a direct array literal? If so, why? My guess is that by some magic the type of the array literal is determined to be an array of optional strings, but that really is just a guess.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’25
Reply to Class not being called?
There are a couple of issues here: Firstly, when do you think that line 57 will run? It seems to be declaring a global, which will run when the app starts. This is not something that is often done in an app. It might be safe, or it might not. Really, you want to run this when your table view controller is constructed. Secondly, you don’t call classes. You call functions and methods. Classes are instantiated to create objects. If you feel you don’t fully understand that, you need to take a step back and learn it properly now. It will make things much clearer going forward. So in your class API declaration, you declare a member called dataTask and assign URLSession.dataTask.resume to it. Note that you have not written resume(), so the resume function is not being called - all that it is doing is assigning the function itself - not the result of calling it - to the dataTask member. Since you’re never resuming (i.e. starting) the data task, its completion handler, and hence line 25, will never run. As for how to fix this - start with the first issue. Get rid of the globals on lines 17-19 and 57. Start your download from some method In the table view controller - probably viewDidLoad. (Honestly, it’s a while since I’ve done anything quite like this so I’m not totally sure of the best place.) You quite probably don’t need an additional class for this; put it all in your view controller.
Mar ’25
Reply to Bundling app with our own SQLite
Can we bundle our app with our own version of SQLite with extensions that we want. Yes, and you should do that. The version that Apple includes depends on the iOS version (see https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS) for a table). If you use the Apple version, there's a danger that your app will break after an iOS update, or will not function on an older iOS version that you are still trying to support but don't test on as well as you should. I was caught out by the latter issue because the sqlite in iOS 14 doesn't support "on conflict" without a column list.
Replies
Boosts
Views
Activity
Aug ’25
Reply to How can I calculate distance and vertical velocity?
Sure, you can integrate acceleration to get velocity and integrate velocity to get distance. But the problem is that you integrate all the errors in the sensor values too, and they quickly dominate. This is a well-known problem that has been studied in the context of submarine, aircraft and spacecraft navigation (pre-GPS) for decades. The solutions tend to be either ever-more precise sensors (which is not something you can change on a phone) and "sensor fusion", where you blend your integrated value with a value from another sensor. One example of sensor fusion is the Kalman Filter - look it up. Do be aware that the sensor values that you get on iOS have probably already been processed in some way by the system before you receive them.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to CGColorRef is NOT a struct
Now, returning to the Objective-C doc, I see this: What you're seeing now is the fixed version. Until yesterday, the * was missing. AgentFriday and I both understand the differences between classes and structs in C, objC and Swift and neither of us was misreading anything. There was no confusion; it was a bug in the documentation generator which has now finally been fixed. user-level bug Huh? There's a difference between "user-level bugs" and "developer-level bugs"? I guess I'd better go and look at all my completely ignored bug reports from the last decades and check if any of them accidentally got in a "user-level" category.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to Install HTTP Live Streaming Tools on Linux ARM
is there a way to run them like Mac OS does with Rosseta? Yes, you can use qemu. If you apt-get install qemu-user qemu-user-binfmt then invoking an x86 executable will use qemu to run it. But there’s a snag - if the executable is dynamically linked, you also need the x86 versions of the libraries that it is linked with. On Debian, this is achieved using ”multiarch”. Of course the performance may not be great! If I were you, I’d work out how to do it using ffmpeg. It’s not fundamentally difficult, though it is somewhat tedious to find all the right incantations.
Topic: Media Technologies SubTopic: Streaming Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to XCode not making bridging header file?
There are two distinct things here: You can export C or C++ (hmmm objC?) to Swift. You can export Swift to C/C++/ObjC. It looks like you want to do the latter. For that, XCode does generate a header but it’s not the file you are looking at in your source tree. It’s a temporary file deep inside the build / intermediates folder structure. The file you are looking at is for exporting in the other direction - as the comment you quoted says - and you can ignore it. Hopefully that is enough to get you a bit further. You may find previous discussions here if you search for e.g. “bridging”.
Replies
Boosts
Views
Activity
Apr ’25
Reply to Unable to use altitude for our use case (NYC MTA)
These levels typically differ by at least 15 feet, which should in theory be well within the precision range of a properly calibrated barometric pressure sensor. Yes, but… However, the absolute altitude values we’re seeing from these APIs are often inaccurate and inconsistent … Apple have ”improved“ them for you. If I were you, I’d look at the raw(?) barometric pressure that should be in CMAltitudeData.pressure. See if this is consistent between devices, and has the resolution that you need to determine station levels. If it does, you just need to know current local sea level pressure. You can probably assume that is constant across your area of interest. Have your app get that from your servers every hour, or whatever. (Out of interest, are the barometric pressures in underground stations affected by the piston effect of the moving trains enough to perturb this analysis?)
Replies
Boosts
Views
Activity
Apr ’25
Reply to Class not being called?
please could you explain why does creating the instance of API not work as a global Maybe it does work. You don’t see your “line 25” because you didn’t call resume() and the download never happened. Maybe the object was constructed, we don’t know. The point is that it shouldn‘t be a global because that’s a bad design, not because it won’t work.
Replies
Boosts
Views
Activity
Mar ’25
Reply to Why does Array's contains(_:) method cause an error when comparing an optional value with a non-optional value in Swift?
Why does the first example work I don’t know. but the second one fails with a compile-time error? What exactly causes this error in the second case, even though both cases involve comparing an optional value with a non-optional value? The declaration of contains that you posted shows that it takes an Element. Element is String. If you don’t pass a String, you’ll get an error. (The fact that it calls another contains method that would work with the optional doesn’t matter; it doesn’t get that far. You could argue that contains should not take an Element but rather an equality-comparable-with-Element; I think that’s possible.) Does contains(_:) behave differently when used with an explicit array variable rather than a direct array literal? If so, why? My guess is that by some magic the type of the array literal is determined to be an array of optional strings, but that really is just a guess.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’25
Reply to Class not being called?
There are a couple of issues here: Firstly, when do you think that line 57 will run? It seems to be declaring a global, which will run when the app starts. This is not something that is often done in an app. It might be safe, or it might not. Really, you want to run this when your table view controller is constructed. Secondly, you don’t call classes. You call functions and methods. Classes are instantiated to create objects. If you feel you don’t fully understand that, you need to take a step back and learn it properly now. It will make things much clearer going forward. So in your class API declaration, you declare a member called dataTask and assign URLSession.dataTask.resume to it. Note that you have not written resume(), so the resume function is not being called - all that it is doing is assigning the function itself - not the result of calling it - to the dataTask member. Since you’re never resuming (i.e. starting) the data task, its completion handler, and hence line 25, will never run. As for how to fix this - start with the first issue. Get rid of the globals on lines 17-19 and 57. Start your download from some method In the table view controller - probably viewDidLoad. (Honestly, it’s a while since I’ve done anything quite like this so I’m not totally sure of the best place.) You quite probably don’t need an additional class for this; put it all in your view controller.
Replies
Boosts
Views
Activity
Mar ’25