I have an Array of [Hashtag]
. The Hashtag NSObject simply holds a variable for the hashtagName which is a String?
. One array is a categoriesArray and the other is a fashionArray. What I would like is when I tap a certain indexPath in my didSelectItemAtIndexPath method, I want to insert the fashionArray into the categoriesArray at the selected Index. The issue I have is that it wants an array of Strings and not an array of Hashtag. How do I achieve this? Thanks guys. Code is below:
import UIKit
class Hashtag: NSObject {
var hashtagName: String?
}
private let reuseIdentifier = "Cell"
class HashtagView: UICollectionViewController, UICollectionViewDelegateFlowLayout {
var categoriesArray = [Hashtag]()
var fashionArray = [Hashtag]()
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.tintColor = .white
navigationItem.title = "Hashtag"
self.collectionView?.backgroundColor = .white
self.collectionView?.register(HashtagCell.self, forCellWithReuseIdentifier: reuseIdentifier)
self.collectionView?.contentInset = UIEdgeInsetsMake(10, 0, 0, 0)
handleFetchCategories()
handleFetchFashionHashtags()
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if indexPath.item == 1 {
// insert here
self.categoriesArray.insert(fashionArray[indexPath.item].hashtagName, at: 1)
print(categoriesArray)
}
}