Post

Replies

Boosts

Views

Activity

Reply to When decoding a Codable struct from JSON, how do you initialize a property not present in the JSON?
I've also encountered this problem in my own framework ColorKit I downloaded a 450000 line JSON database from GitHub and found out it has no id while my SingleColor model is Identifiable AHHHHH So I went to to add id to them one by one for a couple of days and realized I could actually create a struct that's without the id called the SingleColorInit and load the JSON into this model and then casting all of my data into my SingleColor model. Code: public struct SingleColorInit: Codable, Hashable{ public var name: String public var hex: String public var rgb: RGBList public var hsl: HSLList public var luminance: Double } public struct SingleColor: Codable, Hashable, Identifiable{ public var id: UUID = UUID() public var name: String public var hex: String public var rgb: RGBList public var hsl: HSLList public var luminance: Double } let coloKey: [InitColor] = load("database.json") public func database() -> [SingleColor] { var returnData: [SingleColor] = [] for datum in colorKey { returnData.append(SingleColor(name: datum.name, hex: datum.hex, rgb: datum.rgb, hsl: datum.hsl, luminance: datum.luminance)) } returnData.remove(at: 0) return returnData } so when I create a new instance of the object the UUID will be generated. In your case you can do this: struct InitReminder {     var title: String     var dueDate: Date     var notes: String? = nil     var isComplete: Bool = false } struct Reminder: Identifiable {     var id: String = UUID().uuidString     var title: String     var dueDate: Date     var notes: String? = nil     var isComplete: Bool = false } // load your data (I use the load method in Apple's SwiftUI tutorial) let reminders: [Reminder] = load("youdatabase.json") func database() -> [Reminder] {     var returnData: [Reminder] = []     for datum in reminders{         returnData.append(Reminder(title: datum.title, dueDate: datum.dueDate, notes: datum.notes, isComplete: datum.isComplete))     }     return returnData } And then I realized... When you use your data in a SwiftUI(if you use it) List or ForEach, you don't need it to be Identifiable; use each item's self as the id. Just do this: List(yourData, id: \.self) { item in ... } ForEach(yourData, id: \.self) { item in ... } This is problem has annoyed me long time really😂 I'm really happy to share this solution to someone who need it It's really annoying hope it'll help
Topic: Programming Languages SubTopic: Swift Tags:
May ’22
Reply to How to distribute a private Xcode app to a few friends
I too music student written a app for my piano teacher realizing I didn't have a developer license or other ways to distribute it and I'm in COVID lockdown so I couldn't let my teacher come to my home and upload it to her phone as in a physical device run😂 (Hey that's a way if you can) just joking I'll guess you have a developer account. if you have a developer account you have a Developer ID option when archiving your app it says that you can distribute directly to your costumers Also If you find a way to distribute iOS or WatchOS or TVOS app to costumers without using a developer account email me "makabaka1880@outlook.com" Hope it'll help😄
May ’22
Reply to How to create .saver file?
If you create a new Xcode project that's a option "Screen Saver" If you have ever noticed, but, it's in Objective-C🙁(which I can give no suggestions on) But if you integrate Xcode toolchain(if you can find it) into your app and learn about OC, maybe you can make a app that will compile your user's input into OC Code, then if you can, compile the OC code into .saver. But this is really a good app idea but really, really hard.
Topic: App & System Services SubTopic: Core OS Tags:
May ’22
Reply to Swift Playground not accepting my solution
maybe a strange bug and also. a multi-line code block uses three backticks
Replies
Boosts
Views
Activity
May ’22
Reply to App created by Xcode 13.3+ crash on iOS 12 physical devices at launch
Your target sets a higher deployment OS Some SDK (in HealthKit, in your case)for iOS 12 was not in use anymore so Xcode got confused I'm also new just suggesting some possibilities Hope it'll help
Replies
Boosts
Views
Activity
May ’22
Reply to Need help with crash report
Exception Type: EXC_CRASH (SIGABRT) Something important was missing at a bad time
Replies
Boosts
Views
Activity
May ’22
Reply to Help with input files
Check "Compile sth sth sth (which I couldn't remember exactly)" build phase in your project
Replies
Boosts
Views
Activity
May ’22
Reply to When decoding a Codable struct from JSON, how do you initialize a property not present in the JSON?
I've also encountered this problem in my own framework ColorKit I downloaded a 450000 line JSON database from GitHub and found out it has no id while my SingleColor model is Identifiable AHHHHH So I went to to add id to them one by one for a couple of days and realized I could actually create a struct that's without the id called the SingleColorInit and load the JSON into this model and then casting all of my data into my SingleColor model. Code: public struct SingleColorInit: Codable, Hashable{ public var name: String public var hex: String public var rgb: RGBList public var hsl: HSLList public var luminance: Double } public struct SingleColor: Codable, Hashable, Identifiable{ public var id: UUID = UUID() public var name: String public var hex: String public var rgb: RGBList public var hsl: HSLList public var luminance: Double } let coloKey: [InitColor] = load("database.json") public func database() -> [SingleColor] { var returnData: [SingleColor] = [] for datum in colorKey { returnData.append(SingleColor(name: datum.name, hex: datum.hex, rgb: datum.rgb, hsl: datum.hsl, luminance: datum.luminance)) } returnData.remove(at: 0) return returnData } so when I create a new instance of the object the UUID will be generated. In your case you can do this: struct InitReminder {     var title: String     var dueDate: Date     var notes: String? = nil     var isComplete: Bool = false } struct Reminder: Identifiable {     var id: String = UUID().uuidString     var title: String     var dueDate: Date     var notes: String? = nil     var isComplete: Bool = false } // load your data (I use the load method in Apple's SwiftUI tutorial) let reminders: [Reminder] = load("youdatabase.json") func database() -> [Reminder] {     var returnData: [Reminder] = []     for datum in reminders{         returnData.append(Reminder(title: datum.title, dueDate: datum.dueDate, notes: datum.notes, isComplete: datum.isComplete))     }     return returnData } And then I realized... When you use your data in a SwiftUI(if you use it) List or ForEach, you don't need it to be Identifiable; use each item's self as the id. Just do this: List(yourData, id: \.self) { item in ... } ForEach(yourData, id: \.self) { item in ... } This is problem has annoyed me long time really😂 I'm really happy to share this solution to someone who need it It's really annoying hope it'll help
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’22
Reply to How to distribute a private Xcode app to a few friends
I too music student written a app for my piano teacher realizing I didn't have a developer license or other ways to distribute it and I'm in COVID lockdown so I couldn't let my teacher come to my home and upload it to her phone as in a physical device run😂 (Hey that's a way if you can) just joking I'll guess you have a developer account. if you have a developer account you have a Developer ID option when archiving your app it says that you can distribute directly to your costumers Also If you find a way to distribute iOS or WatchOS or TVOS app to costumers without using a developer account email me "makabaka1880@outlook.com" Hope it'll help😄
Replies
Boosts
Views
Activity
May ’22
Reply to SF Symbol for Dark Mode Icon
Metoo
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
May ’22
Reply to Making it to the iOS, Need to test on Simulator
I've never met this before😂 let your costumer get you a phone otherwise tell the costumer you can't do it just joking
Replies
Boosts
Views
Activity
May ’22
Reply to How can I limit the availability of our app to california only
why are u doing this
Replies
Boosts
Views
Activity
May ’22
Reply to xcode13.4 build is too slow
cmd + K
Replies
Boosts
Views
Activity
May ’22
Reply to xcode13.4 build is too slow
Check your Macs background and try to terminate as many process as possible or cmd + k clean build folder or reinstall
Replies
Boosts
Views
Activity
May ’22
Reply to Didn't Autofill sms code at iPhone XR iOS 14.8.1
Sorry what's iPhone XR😂never heard of it
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’22
Reply to About Crash Much
I think it's about sth about privacy or code signing not sure seen a few posts like this
Replies
Boosts
Views
Activity
May ’22
Reply to How to create .saver file?
If you create a new Xcode project that's a option "Screen Saver" If you have ever noticed, but, it's in Objective-C🙁(which I can give no suggestions on) But if you integrate Xcode toolchain(if you can find it) into your app and learn about OC, maybe you can make a app that will compile your user's input into OC Code, then if you can, compile the OC code into .saver. But this is really a good app idea but really, really hard.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
May ’22
Reply to ARKit problems with U shaped tables and hallways
Strange Bug?
Topic: Spatial Computing SubTopic: ARKit Tags:
Replies
Boosts
Views
Activity
May ’22