-3
 override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
    if segue.identifier == "shoesDetails" {
        let indexPath = self.table.indexPathForSelectedRow()    
        let shoesCon:ShoesTableControler = segue.destinationViewController as! ShoesTableControler
        let shoesCategories:RepoSitory = arrofRepository[indexPath!.row]       
        shoesCon.object = shoesCategories
    }
 }

class ShoesTableControler: UIViewController {
    var object = [ProductShoes]()
}

class ProductShoes {
    var product_id : String
    var product_name : String

    init(json :NSDictionary) {
        self.product_id = json["product_id"] as! String
        self.product_name = json["product_name"] as! String
    } 
    class RepoSitory {
var name : String
var ids : String

init(json :NSDictionary) {
   self.name = json["category_name"] as! String
   self.ids = json["id"] as! String



}

}

I have 3 classes in firstViewController. We show the data it's done. After that, when user click on specific cell, then show the data. Now I have created the ShoesTableController and in ShoesTableController we create the Product Class obj. I want to access this. The problem is in this line in Objective C. I am doing this and it is working perfect but in swift it does know what happened:

 shoesCon.object = shoesCategories 
  • 1
    possible duplicate of [How do you share data between view controllers and other objects in Swift?](http://stackoverflow.com/questions/29734954/how-do-you-share-data-between-view-controllers-and-other-objects-in-swift) – nhgrif Jun 15 '15 at 11:58
  • i see this but my problem is different bro – Ahmad Durrani Jun 15 '15 at 12:02
  • 3
    Then as a start, you need to explain what's not working. What's happening? Is there a compile time error? Is it crashing? Is it launching missiles? What's happening that's different from your expectations? – nhgrif Jun 15 '15 at 12:03
  • bro sorry i think so you mind it error is this "Cannot Assign a value of type Class to a value of type ProductShoes" – Ahmad Durrani Jun 15 '15 at 12:13
  • Cannot Assign a value of type RepoSitory to a value of type ProductShoes – Ahmad Durrani Jun 15 '15 at 12:29
  • According to the code you have posted, `shoesCategories` is of type `RepoSitory`. Whereas `shoesCon.object` is defined as an array of `ProductShoes`. That is why you are unable to assign the value of `shoesCategories` to the object. – lostInTransit Jun 15 '15 at 12:45
  • but in Objective C i am doing this and properly work it than how we are doing in swift? – Ahmad Durrani Jun 15 '15 at 12:47

1 Answers1

1
 override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
    if segue.identifier == "shoesDetails" {


    let indexPath = self.table.indexPathForSelectedRow()


   let shoesCon:ShoesTableControler = segue.destinationViewController as! ShoesTableControler
    let shoesCategories:RepoSitory = arrofRepository[indexPath!.row]

       shoesCon.object = shoesCategories
         }
    }

 class ShoesTableControler: UIViewController {

var object : RepoSitory?

its solve my problem i have my own mistake sorry for posting this question