Post

Replies

Boosts

Views

Activity

Relationships between structs and detecting changes
I'm currently working on an app which has a number of different data objects with relationships between them. For example, there is a Building struct: struct Building { let id: UUID var name: String } There is also an Address struct, which has a Building property: struct Address: { let id: UUID var addressText: String var building: Building } When I change the name of the Building I would like it to update for all the corresponding Address objects. Because structs are value types, this doesn't happen at present. I could fix this by changing struct to class, but because I'm working with SwiftUI that's not desirable. I could fix this by updating the Address to store the id of the Building instead but having to look up the name of the corresponding building each time I want it feels messy to me. Is there some other approach I'm missing? Or a recommended best practice way of handling relationships between structs?
3
0
430
Jun ’22
DES in Swift using CommonCrypto
I'm working on an app which uses CoreNFC to read the details of student ID cards. The details I need to retrieve are stored on the card in an encrypted file and I need to use DES to decipher them. I've been trying to use CommonCrypto to do this, but have been unable to get the CCCrypt() function working because it uses pointers and I'm coming at this from Swift. The CCCrypt function takes eleven parameters. The last three are for the results of the decryption: dataOut is an UnsafeMutableRawPointer! dataOutAvailable is an Int dataOutMoved is an UnsafeMutablePointerInt! Can anyone give me any pointers (no pun intended) on how to correctly declare variables for dataOut and dataOutMoved, and then turn the results back into a regular Swift Data object?
2
0
1.3k
Feb ’21