Btw this is all the code related to my protocol and what I am trying to transfer. As for the data on the results
print("invoked HockeyDetailVC is", self)
gives me invoked HockeyDetailVC is <LearnHockey.HockeyDetailVC: 0x7fe0b3026200>. Can you explain the 0x7fe0b3026200.
print("The delegate is nil")
gives me The delegate is nil.
print("destination HockeyDetailVC is", hockeyDetailVC)
This does not print anything to my console.
Post
Replies
Boosts
Views
Activity
Yeah my class conforms to the protocol addThis class favouritesVC: UITableViewController, addThis . I intialized my delegate to not be nil and it still does not show the print statement from sendData.
what I mean by content is the content view.
Okay I see what your saying but how come in my experience the view can scroll in a direction where the content is smaller instead of larger?
Alright I figured it out finally I had to make another array to filter my JSON data.
It's not the search string and the array is complete and when parseJson() is run it shows all the cells. When I type E it shows less cells when I type n it shows even less cells, when I type f it shows even less cells but when I delete the f it shows 0 cells and when I delete n it again shows 0 cells so I have to delete everything to restart everything.
This function shows the number of cells I have displayed.
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
print("Number of cells:", cPlayerArr.count)
return cPlayerArr.count
}
for my print("search for: ", searchText, searchText.count) it shows the exact amount of characters and the word in the searchbar even when I delete characters. I added the parseJson() right before the filter and it paused it like you said and reset the array. I don't have a textField delegate. This is my cellforItemAt I think thats what you wanted because there is no itemAtRow.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "colcell", for: indexPath) as! PlayerColCell
let item = cPlayerArr[indexPath.row]
cell.layer.borderColor = UIColor.black.cgColor
cell.layer.borderWidth = 0.5
cell.contentView.backgroundColor = UIColor(red: 102/256, green: 255/256, blue: 255/256, alpha: 0.66)
cell.update(with: item)
return cell
}
This is what I have for my class CurrentPlayers.
CurrentPlayers {
var photoUrl: String
var position: String
var team: String
var yahooName: String
var birthCity: String
var status: String
init(photoUrl: String, position: String, team: String, yahooName: String, birthCity: String, status: String) {
self.yahooName = yahooName
self.photoUrl = photoUrl
self.position = position
self.team = team
self.birthCity = birthCity
self.status = status
}
}
My parseJson func performs a get request for an API and it populates the array with JSON data.
func parseJson() {
cPlayerArr = []
let url = //url I am using to get data from
var request = URLRequest(url: URL(string: url)!)
request.httpMethod = "GET"
let configuration = URLSessionConfiguration.default
let session = URLSession(configuration: configuration, delegate: nil, delegateQueue: OperationQueue.main)
let task = session.dataTask(with: request) { (data, response, error) in
if (error != nil) {
print("error")
} else {
do {
let fetchedData = try JSONSerialization.jsonObject(with: data!, options: .mutableLeaves) as! NSArray
for eachPlayerNow in fetchedData {
let eachPlayer = eachPlayerNow as! [String: Any]
let player = eachPlayer["YahooName"] as?
String
let position = eachPlayer["Position"] as? String
let photoUrl = eachPlayer["PhotoUrl"] as? String
let team = eachPlayer["Team"] as?
String
let birthCity = eachPlayer["BirthCity"] as? String
let status = eachPlayer["Status"]
as? String
self.cPlayerArr.append(CurrentPlayers.init(photoUrl: photoUrl ?? "", position: position ?? "", team: team ?? "", yahooName: player ?? "", birthCity: birthCity ?? "", status: status ?? ""))
}
self.collections.reloadData().			
}
catch {
print("error 2")
}
}
}
task.resume()
}
I'm thinking it would be better to do a collectionview in a scrollview so things can be closer together.
The issue I have is I had a collectionview with 2 rows of data I got from an API, but I could not scroll down (could only scroll horizontally), so I had to add a tableview and put the collectionview inside it however the issue is my 2 tableview cells show the same thing but I want them to show different data.
Alright I have an example lets say you have a collectionview and you display just names of people, you can have 2 rows of different names but I am not sure how to have those 2 rows of the different names in a tableview.
Alright I made a func that fixes the issue using the alpha.
func goToZero() {
if otSlider.value == 0 {
otShape.alpha = 0
} else if efSlider.value == 0 {
efShape.alpha = 0
} else if ifSlider.value == 0 {
ifShape.alpha = 0
} else {
otShape.alpha = 1
efShape.alpha = 1
ifShape.alpha = 1
}
}
Okay your solution does work but is there any way to tap on it if it repeats or would I have to change the UILabel to a UIView?
Thank you for your patience still have a lot to learn.
I mean UITapGestureRecognizer not Pan.