Post

Replies

Boosts

Views

Activity

Using map and/or filter to extract an element from an array of dictionaries which have nested dictionaries
I am trying to use filter (I don't think map applies here, but I am not sure) to extract an element from an array of dictionaries which themselves contain dictionaries. let participants = [ [ "id" : 1, "team" : [ [ "name" : "John", "job" : "teacher" ], [ "name" : "Paul", "job" : "coach" ], [ "name" : "Mary", "job" : "chef" ] ] ], [ "id" : 7, "team" : [ [ "name" : "Simon", "job" : "engineer" ], [ "name" : "Laura", "job" : "writer" ], [ "name" : "Peter", "job" : "bartender" ] ] ], [ "id" : 4, "team" : [ [ "name" : "Igor", "job" : "pianist" ], [ "name" : "Mary", "job" : "bartender" ], [ "name" : "Denise", "job" : "accountant" ] ] ] ] I want to extract from the above array of dictionaries the element whose "team" value (which itself is an array of dictionaries) has an element whose "job" value is "writer". In other words, for the purpose of this exercise, I want the 2nd element of the participants array which is: [ "id": 7, "team": [ [ "name": "Simon", "job": "engineer" ], [ "name": "Laura", "job": "writer" ], [ "name": "Peter", "job": "bartender" ] ] ] How would I use map and/or filter to accomplish this?
0
0
496
Feb ’24
In the Platforms window, difference between iOS and iOS Simulator
I was just prompted in Xcode to update/download iOS 17.2. I wasn't paying attention but I think it was downloading iOS 17.2 and then iOS 17.2 Simulator. The latter failed during "Verifying iOS 17.2 simruntime". I opened Xcode > Settings > Platforms and I see iOS 17.2, but I don't see iOS 17.2 Simulator. Must I have both iOS 17.2 and iOS 17.2 Simulator? Do I always have to have iOS xyz and iOS xyz Simulator present in the Platforms window? What is the difference between the two? What's the iOS 17.2 for?
3
0
1.1k
Dec ’23
Color Literal behaves inconsistently in Xcode 13.2.1
Color Literal used to be recognized in the Xcode IDE. As soon as you type "color", the autosuggestion dropdown shows "UIColor Color Literal" and you can simply select it without typing anything more. A small color square would appear where you can visually select your desired color. There appears to no longer be any shortcut/ autosuggestion for color literal. Now, I have to type "#colorLiteral(" (yes, pound sign, uppercase L, and the left parenthesis) in order for the little color square to appear where I can select my color. In addition, its behavior is inconsistent. That little color square appears only if I do something like: If the color literals are arguments in a function call, the little color square doesn't appear anymore. Instead, the full-blown RGB function appears, in which case it is not possible to bring up the color selection popup to visually select your desired color: Has this bug been reported to Apple, or is there an alternate way to work with color literals in Xcode 13.2.1?
1
0
2.7k
Dec ’21
How can an app prove that it is, in fact, encrypting data?
Apps like Password Managers and such claim to encrypt your sensitive data, and only transmit and store your data on their servers in encrypted form, never in plain text. But how are we supposed to believe that? Just take their word for it? Who's to say that their developers won't accidentally (or intentionally!) make a mistake in their code at some point and get to see your sensitive data? I am asking because I am currently writing an app using the Swift-Crypto package to do AES encryption. I save the user's data in encrypted form in Core Data on the device as well as mirror it on their iCloud account using CloudKit. When I submit the app to Apple for review, without looking at the source code, will they be able to verify 100% that my app actually and correctly encrypts all the data so that users can confidently trust that their data will be safe? How can we be sure?
2
0
1.2k
Nov ’21
Using map and/or filter to extract an element from an array of dictionaries which have nested dictionaries
I am trying to use filter (I don't think map applies here, but I am not sure) to extract an element from an array of dictionaries which themselves contain dictionaries. let participants = [ [ "id" : 1, "team" : [ [ "name" : "John", "job" : "teacher" ], [ "name" : "Paul", "job" : "coach" ], [ "name" : "Mary", "job" : "chef" ] ] ], [ "id" : 7, "team" : [ [ "name" : "Simon", "job" : "engineer" ], [ "name" : "Laura", "job" : "writer" ], [ "name" : "Peter", "job" : "bartender" ] ] ], [ "id" : 4, "team" : [ [ "name" : "Igor", "job" : "pianist" ], [ "name" : "Mary", "job" : "bartender" ], [ "name" : "Denise", "job" : "accountant" ] ] ] ] I want to extract from the above array of dictionaries the element whose "team" value (which itself is an array of dictionaries) has an element whose "job" value is "writer". In other words, for the purpose of this exercise, I want the 2nd element of the participants array which is: [ "id": 7, "team": [ [ "name": "Simon", "job": "engineer" ], [ "name": "Laura", "job": "writer" ], [ "name": "Peter", "job": "bartender" ] ] ] How would I use map and/or filter to accomplish this?
Replies
0
Boosts
0
Views
496
Activity
Feb ’24
In the Platforms window, difference between iOS and iOS Simulator
I was just prompted in Xcode to update/download iOS 17.2. I wasn't paying attention but I think it was downloading iOS 17.2 and then iOS 17.2 Simulator. The latter failed during "Verifying iOS 17.2 simruntime". I opened Xcode > Settings > Platforms and I see iOS 17.2, but I don't see iOS 17.2 Simulator. Must I have both iOS 17.2 and iOS 17.2 Simulator? Do I always have to have iOS xyz and iOS xyz Simulator present in the Platforms window? What is the difference between the two? What's the iOS 17.2 for?
Replies
3
Boosts
0
Views
1.1k
Activity
Dec ’23
Color Literal behaves inconsistently in Xcode 13.2.1
Color Literal used to be recognized in the Xcode IDE. As soon as you type "color", the autosuggestion dropdown shows "UIColor Color Literal" and you can simply select it without typing anything more. A small color square would appear where you can visually select your desired color. There appears to no longer be any shortcut/ autosuggestion for color literal. Now, I have to type "#colorLiteral(" (yes, pound sign, uppercase L, and the left parenthesis) in order for the little color square to appear where I can select my color. In addition, its behavior is inconsistent. That little color square appears only if I do something like: If the color literals are arguments in a function call, the little color square doesn't appear anymore. Instead, the full-blown RGB function appears, in which case it is not possible to bring up the color selection popup to visually select your desired color: Has this bug been reported to Apple, or is there an alternate way to work with color literals in Xcode 13.2.1?
Replies
1
Boosts
0
Views
2.7k
Activity
Dec ’21
How can an app prove that it is, in fact, encrypting data?
Apps like Password Managers and such claim to encrypt your sensitive data, and only transmit and store your data on their servers in encrypted form, never in plain text. But how are we supposed to believe that? Just take their word for it? Who's to say that their developers won't accidentally (or intentionally!) make a mistake in their code at some point and get to see your sensitive data? I am asking because I am currently writing an app using the Swift-Crypto package to do AES encryption. I save the user's data in encrypted form in Core Data on the device as well as mirror it on their iCloud account using CloudKit. When I submit the app to Apple for review, without looking at the source code, will they be able to verify 100% that my app actually and correctly encrypts all the data so that users can confidently trust that their data will be safe? How can we be sure?
Replies
2
Boosts
0
Views
1.2k
Activity
Nov ’21