-2

I know that this question was asked several times before but none of those solutions don't work in my case.

I have two classes: in the first one (class A) i get data from the user and contain it in the property:

@property (nonatomic, retain) NSMutableArray *firstClassArray;

And synthesize it. At the same time, i have class B, where a property is taking place.

@property (strong, nonatomic) NSMutableArray *games;

I tried do this in the ViewDidLoad:

CLassA *a = [[ClassA alloc] initWithNibName:@"ClassA" bundle:nil];
games = a.firstClassArray;

and this

CLassA *a = [[CLassA alloc] init];
a.view;
games = a.firstClassArray;

All in all, i need to get an information from firstClassArray and store it in games array to show in TableView. How can i do it?

What is going wrong in my code?

Thanks!

teralion
  • 72
  • 5
  • 2
    You create a new instance of ClassA and receive a value from it. What do you expect different from nil in this case or 0 in other cases? And what exactly do you expect from `a.view`? – Hermann Klecker Mar 24 '14 at 17:16
  • If none of the solutions work for you, it would help if you could explain a little about why.. – Monolo Mar 24 '14 at 17:27
  • @Monolo They don't help me because if i add new object to the first array, pass it to the second and make this: NSLog("%d", arrayB,count); It shows 0 instead of 1. And so on. – teralion Mar 24 '14 at 17:36

1 Answers1

1

In an instance of Class A do:

ClassB *b = [[ClassA alloc] initWithSomething:something];
b.games = self.firstClassArray;

Or, if ClassB is implemented accordingly, do:

ClassB *b = [[ClassA alloc] initWithSomething:something andGames:self.firsClassArray];
Hermann Klecker
  • 14,039
  • 5
  • 48
  • 71