0

When i run my app this exception occurs in number of item in section on return

here is my code :

import UIKit

import Alamofire import SwiftyJSON

class DetailPage: UIViewController,UICollectionViewDataSource,UICollectionViewDelegate {

@IBOutlet weak var MyOtherProductsOfStoreCollectionView: UICollectionView!
@IBOutlet weak var MySameProductsCollectionView: UICollectionView!


@IBOutlet weak var img1: UIImageView!
@IBOutlet weak var profilePic: UIImageView!
@IBOutlet weak var username: UILabel!
@IBOutlet weak var productsCount: UILabel!
@IBOutlet weak var price: UILabel!
@IBOutlet weak var desc: UILabel!





var sameData:[SameAndOtherData]?
var otherData:[SameAndOtherData]?
var alldata: [PopulerUrunlerData]?
var indexPath: IndexPath?




override func viewDidLoad() {
    super.viewDidLoad()

    if let indexPath = self.indexPath, let popularUrunlerData = self.alldata?[indexPath.row] {


        img1.downloadImage(from: popularUrunlerData.imgUrl!)
        profilePic.downloadImage(from: popularUrunlerData.userpic!)
        username.text = popularUrunlerData.username
        productsCount.text = String( format:"%d", popularUrunlerData.productsCount!)
        price.text = String(format: "%.1f", popularUrunlerData.price!)
        desc.text = popularUrunlerData.desc




        let id = popularUrunlerData.instagramId
        let name = popularUrunlerData.username
        sameProducts(from: "https://api.shopsta.com/product/\(id!)/similar")
        otherProductsOfStore(from: "https://api.shopsta.com/product/\(name!)/\(id!)/others")

    }


    MyOtherProductsOfStoreCollectionView.delegate = self;
    MySameProductsCollectionView.delegate = self;
    MyOtherProductsOfStoreCollectionView.dataSource = self;
    MySameProductsCollectionView.dataSource = self;

}

and my collectionView funds :

  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

    if (collectionView == self.MySameProductsCollectionView){

        return (self.sameData?.count)!
    }
    else {

        return (self.otherData?.count)!
     }

}




func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    if collectionView == self.MySameProductsCollectionView {

        let cella = collectionView.dequeueReusableCell(withReuseIdentifier: "sameProducts", for:
            indexPath as IndexPath) as! SameProductsCollectionViewCell
        cella.img.downloadImage(from: (sameData?[indexPath.row].image)!)
        return cella
    }
    else {

       let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "otherProducts", for: indexPath as IndexPath) as! OtherProductsOfStoreCollectionViewCell
        cell.img.downloadImage(from: (otherData?[indexPath.row].image!)!)
        return cell
    }

}

 }
ismailtsn92
  • 21
  • 1
  • 4
  • The error message is fairly explicit: you'll need to put the google-services.json from your Firebase project into `/Users/ismail/AndroidStudioProjects/BusTrackingApp/app`. – Frank van Puffelen Aug 09 '16 at 15:19

1 Answers1

4

You are missing google-services.json file in you project. Check docs to determine how to generate it and add it to BusTrackingApp/app folder.

gar_r
  • 347
  • 5
  • 13