How can I sort dates to nearest date in Swift
I started studying programming languages quite recently
The essence of the problem is this – in SwiftData I created a model with the property of the date of birth and by picker I want to sort from the oldest, from the youngest and by the date closest to today
Merging two dictionaries with common key in Swift
I have an array of books aka struct Book in the Top100Model below. I also have an array of books aka struct Data as well in the ISBNModel below. Both arrays have the same number of books and have a common property isbn13 which is a string holding a number. Id like to either merge the arrays so that it contains all the properties from Book in the Top100Model but add another two properties from the ISBNModel and copies the ‘subjects’ and ‘synopsis’ properties from the ISBNModel to this Top100Model based on the matching isbn13 values or merge them into a new dictionary. The code below to merge the arrays is returning empty
Merging two dictionaries with common key in Swift
I have an array of books aka struct Book in the Top100Model below. I also have an array of books aka struct Data as well in the ISBNModel below. Both arrays have the same number of books and have a common property isbn13 which is a string holding a number. Id like to either merge the arrays so that it contains all the properties from Book in the Top100Model but add another two properties from the ISBNModel and copies the ‘subjects’ and ‘synopsis’ properties from the ISBNModel to this Top100Model based on the matching isbn13 values or merge them into a new dictionary. The code below to merge the arrays is returning empty
Merging two dictionaries with common key in Swift
I have an array of books aka struct Book in the Top100Model below. I also have an array of books aka struct Data as well in the ISBNModel below. Both arrays have the same number of books and have a common property isbn13 which is a string holding a number. Id like to either merge the arrays so that it contains all the properties from Book in the Top100Model but add another two properties from the ISBNModel and copies the ‘subjects’ and ‘synopsis’ properties from the ISBNModel to this Top100Model based on the matching isbn13 values or merge them into a new dictionary. The code below to merge the arrays is returning empty
Merging two dictionaries with common key in Swift
I have an array of books aka struct Book in the Top100Model below. I also have an array of books aka struct Data as well in the ISBNModel below. Both arrays have the same number of books and have a common property isbn13 which is a string holding a number. Id like to either merge the arrays so that it contains all the properties from Book in the Top100Model but add another two properties from the ISBNModel and copies the ‘subjects’ and ‘synopsis’ properties from the ISBNModel to this Top100Model based on the matching isbn13 values or merge them into a new dictionary. The code below to merge the arrays is returning empty
Merge two arrays of objects into a dictionary with a condition
I have an array of books aka struct Book in the Top100Model below. I also have an array of books aka struct Data as well in the ISBNModel below. Both arrays have the same number of books and have a common property isbn13 which is a string holding a number. Id like to create a dictionary to merge the arrays so that it contains all the properties from Book in the Top100Model but add another two properties from the ISBNModel and copies the ‘subjects’ and ‘synopsis’ properties from the ISBNModel to this dictionary based on the matching isbn13 values. In trying the code below I’m getting a ‘Generic struct Dictionary requires that Book conforms to Hashable’. If I add the Hashable identifier to Book then it gives an error that it must be Equatable also
Merge two arrays of objects into a dictionary with a condition
I have an array of books aka struct Book in the Top100Model below. I also have an array of books aka struct Data as well in the ISBNModel below. Both arrays have the same number of books and have a common property isbn13 which is a string holding a number. Id like to create a dictionary to merge the arrays so that it contains all the properties from Book in the Top100Model but add another two properties from the ISBNModel and copies the ‘subjects’ and ‘synopsis’ properties from the ISBNModel to this dictionary based on the matching isbn13 values. In trying the code below I’m getting a ‘Generic struct Dictionary requires that Book conforms to Hashable’. If I add the Hashable identifier to Book then it gives an error that it must be Equatable also
Merging two arrays into a third array with a condition
I have an array of books aka struct Book in the Top100Model below. I also have an array of books aka struct Data as well in the ISBNModel below. Both arrays have the same number of books and have a common property isbn13 which is a string holding a number. Id like to create a third array or merge the arrays so that it contains all the properties from Book in the Top100Model but add another two properties to the Top100Model or third which copies the ‘subjects’ and ‘synopsis’ properties from the ISBNModel to this array based on the matching isbn13 values.
Searching for part of a string within an array
The below code works well to filter books by author but only works when search string is equal to full string. Example where authors contains full names [“Jack Nicklaus”, “Arnold Palmer”, “Sam Snead”]
Swift Nested ObservableObject not updating Timer view
I’m trying to program a small interval timer application with Swift and am stuck on not being able to update my view probably.
The view is updated only when one interval ends, so the timer gets to 0 and a new interval starts with a new time.