Stack Exchange
Object in an object?
I have a class which consist of three strings and an array.
That array contains another object list.
when i try to access and add new object to that array, it do not work.
For instance;
CarList{

NSString *carName;
NSString *carId;
NSMutableArray *carTires;
}

CarTyres is another class
 visits = [[NSMutableArray alloc]init];

    Visits * visit1 = [[Visits alloc]init];

    visit1.visitDate = @"13.07.2013";

    [visits addObject:visit1];

    Visits * visit2 = [[Visits alloc]init];

    visit2.visitDate = @"10.07.2013";

    [visits addObject:visit2];


    orderList = [[NSMutableArray alloc]init];

    OrderList *order1 = [[OrderList alloc]init];

    order1.monthName1 = @"Mart";
    order1.monthName2 = @"Nisan";
    order1.monthName3 = @"Mayıs";

    Orders *firstOrder = [[Orders alloc]init];

    firstOrder.orderName = @"Voltaren";
    firstOrder.monthCount1 = @"20";
    firstOrder.monthCount2 = @"43";
    firstOrder.monthCount3 = @"11";
    firstOrder.rangeMonthCount = @"74";

    [order1.orders addObject:firstOrder];

    [orderList addObject:order1];

at the last line object is not added.
How to solve it?

You have to initialize the carTires array first.

Bearing in mind the fact that code above wouldn't even compile in its current state, how you do know that the object isn't being added to the array?

i have written this code as pseudo code, just to tell the story, i will update with my code.

Sounds like a plan. (Otherwise, we're just clutching at straws.)

updated my code above

change to this, hope this helps u :) 

    //suppose u hav an instance
   CarList{

    NSString *carName;
    NSString *carId;
    NSMutableArray *carTires;
   }


   //in another class
   CarTire{

   NSString *tireName;
   NSString *tireId;
   }

   CarList * carlist = [CarList alloc]init];

  carlist.carName =@"Blabla";
  carlist.carId =@"idx234";

    CarTire *tire1 = [CarTire alloc]init];

   tire1.tireName = @"Blibli";
   tire1.tireId = @"idT211";

  [carlist.carTires addObject:tire1];//you are adding to CarList object array


