How to set the array of objects from a class to a controller in tabbarviewcontroller
i have a class songsData in this i am parsing a json object and adding the song objects to an array and later setting this array of objects in a viewcontroller of atabbarviewcontroller. while accessing its showing o objects in tabbarcontroller
how to gt that array in the viewcontroller of an tabbarcontroller.
thanks
in songsData.m
-(void)loadData{
OnAirViewController *oAVC = [[OnAirViewController alloc]init];//the view controller in Tabbarcontroller
oAVC.songs = [self parsingTheJson:@"http:....."];
NSLog(@" count..%d",[songs count]);//gives 153
}
in onAirViewController.. its givi开发者_Go百科ng
NSLog(@" count..%d",[songs count]);//gives 0
Are you sure that the controller that is in your tab bar is the exact same instance of OnAirViewController
that you are creating in loadData
? Assuming that the tab bar controller is already initialized when loadData
is called, you would not create a fresh instance of OnAirViewController
but rather assign the array to the existing OnAirViewController
instance.
精彩评论