I am trying to filter a TWTRListTimelineDataSource(listSlug:listOwnerScreenName:apiClient) but I am having trouble figuring out how to convert the array into a set that the filter will accept.
I have 2 arrays, memberIDs which has about 30 Strings, then userFavorites that has whichever memberIDs you have favorited. I have a TWTRTimelineView that displays tweets from all the members but I want to give an option to only show tweets from favorites.
This is my original code:
var handlesToRemove = [String]()
for id in memberIDs {
if userFavorites.contains(id!) {
} else {
handlesToRemove.append(id!)
}
}
let filter = TWTRTimelineFilter()
filter.handles = handlesToRemove
dataSource.timelineFilter = filter
But it gave me an error that ‘[String]’ is not convertible to Set?
I have tried changing handlesToRemove to Set<AnyHashable>() and using .insert(id!) instead of append().
That gives me the correct handlesToRemove but the filter doesn’t work, the timeline is unchanged.
Like the documentation if I hardcode filter.handles = ["memberid1","memberid2"] it works and removes those ID’s, but I need the user to be able to make their own filter.
Is this possible or is there a better way to show a timeline with an Array of handles?