Help a wee lad wit a Cocoa problem

hardjalard

Registered
Here is my problem (keep in mind I am a still developing young programmer and the objective language phenamenon was only presented to me lately)

I have a simple program that runs 3 windows (3 nib files in PB, and 3 seperate classes - I also have a class that is used to open the new windows). Between these windows, window ONE displays an array, window TWO deletes from the array, and window THREE adds to the array.

I was told to just make a method in each class sending the array as a return function (strange wording, but I hope it makes sense). So I did, then I imported each class into each class and created an instance of each class in each class. But, the deed was not done. The array didn't appear in window TWO inorder to select which object to delete, nor was an object added when I tried to do this. This is the only problem with the program, no errors or warnings were received at run time.

Could someone describe in detail how to pass an array from one class to the next, keeping in mind that the instance of the class (in Interface Builder, the window representing the class) is still running when the next class opens? (Could the problem be in creating multiple instances of a class - creating one when one is already "running"?) PLEASE HELP!
 
Here's one thing you could do: Set the class of the "File's Owner" in each of your nibs to your class. Make all necessary connections to File's Owner now that it will be the instance of your class. Then, when you load the nib using loadNibNamed:eek:wner:, pass in the same one instance of that class as the owner for all three nibs.
 
More specifically (and sort of generally) how do I pass one array to three different classes? If I just declare it in main.m, it won't do the trick will it? What is the trick?
 
You can create your own new function for the classes that takes a pointer to the array, and when you create objects from the classes, pass a pointer to the object's constructor.
 
Back
Top