I got this calling api function:
func searchResults(){
let urlString = "http://dev.jocom.com.my/feed"
Alamofire.request(.POST, urlString , parameters: ["req" : "pro_name", "code" : searchString!])
.responseData { response in
switch response.result {
case .Success:
let apiSearchXML = SWXMLHash.parse(response.data!)
for elem in apiSearchXML["rss"]["channel"]["item"]{
self.imageURL.append(elem["thumb_1"].element!.text!)
self.name.append(elem["name"].element!.text!)
}
print(self.name)
case .Failure(let error):
print(error)
}
}
}
It seems ok when i print the output out, the array its containing something. But when i try to call it to display inside my collection view, it didnt return row, and it become empty, why is it?
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.name.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! SearchResultsCollectionViewCell
cell.titleLabel.text = "abc"
cell.setNeedsDisplay()
return cell
}