Post

Replies

Boosts

Views

Activity

Reading (NS)Bundle in iOS after relaunch
Sorry, I did not have a catchier title: Prelude Avid followers of my Twitter account know: I was looking for an easy, preferably human editable container for documents, and — being the old Mac developer I am — I went with bundles, stored in the Documents folder. The Problem At some point in my app, the user can choose which file to use. And then, of course, on next launch, that file should be used. Selecting the file works all nice and well, including reading from the created Bundle. The problem occurs when the App is relaunched, and reads the absoluteString of the file from the UserDefaults. This works, and I can create a URL from it. But creating a bundle fails, and I don't get any error. This happens on iOS 15 and 16, on device and in the simulator. Is this some permissions things? Is the url not formatted correctly? What is going on? To Reproduce I have created a sample App here: https://github.com/below/BundleSample Launch the App, in the Simulator or on device Select "Copy Bundle" (You can "Test Resource Bundle", but it does not matter) Finally, select "Test Documents Bundle". You should see a picture Close the app, either by stopping it in Xcode or force quit Restart the App Expected Result You see the picture Acutal Result You see the "Gear" placeholder
3
0
1.3k
Sep ’22
Weird DateFormatter behavior
I am seeing a weird behavior of the date formatter (Full code is below). When run, this will give the following output: 57: 1 month, 3 weeks, 5 days 58: 1 month, 3 weeks, 6 days 59: 2 months 60: 2 months, 1 day 61: 2 months 62: 2 months, 1 day 63: 2 months, 2 days So both 59 days and 61 days are 2 months, and both 60 and 62 days are 2 months and 1 day. This of course is especially weird because this means, 2 months also comes after 2 months and a day. Can someone explain to me what is going on here? import Foundation let formatter = DateComponentsFormatter() formatter.unitsStyle = .full let calendar = Calendar(identifier: .gregorian) let today = calendar.date(from: DateComponents(year: 2025, month: 7, day: 26))! for day in 57...63 { let startDate = calendar.date(byAdding: .day, value: -day, to: today)! let components = calendar.dateComponents([.day, .weekOfMonth, .month,. year], from: startDate, to: today) let result = formatter.string(from: components)! print ("\(String(format: "%3d", day)): \(result)") }
4
0
306
Jul ’25
Reading (NS)Bundle in iOS after relaunch
Sorry, I did not have a catchier title: Prelude Avid followers of my Twitter account know: I was looking for an easy, preferably human editable container for documents, and — being the old Mac developer I am — I went with bundles, stored in the Documents folder. The Problem At some point in my app, the user can choose which file to use. And then, of course, on next launch, that file should be used. Selecting the file works all nice and well, including reading from the created Bundle. The problem occurs when the App is relaunched, and reads the absoluteString of the file from the UserDefaults. This works, and I can create a URL from it. But creating a bundle fails, and I don't get any error. This happens on iOS 15 and 16, on device and in the simulator. Is this some permissions things? Is the url not formatted correctly? What is going on? To Reproduce I have created a sample App here: https://github.com/below/BundleSample Launch the App, in the Simulator or on device Select "Copy Bundle" (You can "Test Resource Bundle", but it does not matter) Finally, select "Test Documents Bundle". You should see a picture Close the app, either by stopping it in Xcode or force quit Restart the App Expected Result You see the picture Acutal Result You see the "Gear" placeholder
Replies
3
Boosts
0
Views
1.3k
Activity
Sep ’22
How is the Xcode 15 Beta download supposed to work?
After I realized that the download site now tries to open a popup, I was able to get the download for Xcode 15 Beta and the selected Simulator SDKs Now, no matter where I unpack and start Xcode 15, it wants to re-download these files. What is the way this is supposed to work? Where should I put my downloads and uncompressed files?
Replies
3
Boosts
2
Views
3.1k
Activity
Jun ’23
Weird DateFormatter behavior
I am seeing a weird behavior of the date formatter (Full code is below). When run, this will give the following output: 57: 1 month, 3 weeks, 5 days 58: 1 month, 3 weeks, 6 days 59: 2 months 60: 2 months, 1 day 61: 2 months 62: 2 months, 1 day 63: 2 months, 2 days So both 59 days and 61 days are 2 months, and both 60 and 62 days are 2 months and 1 day. This of course is especially weird because this means, 2 months also comes after 2 months and a day. Can someone explain to me what is going on here? import Foundation let formatter = DateComponentsFormatter() formatter.unitsStyle = .full let calendar = Calendar(identifier: .gregorian) let today = calendar.date(from: DateComponents(year: 2025, month: 7, day: 26))! for day in 57...63 { let startDate = calendar.date(byAdding: .day, value: -day, to: today)! let components = calendar.dateComponents([.day, .weekOfMonth, .month,. year], from: startDate, to: today) let result = formatter.string(from: components)! print ("\(String(format: "%3d", day)): \(result)") }
Replies
4
Boosts
0
Views
306
Activity
Jul ’25