Refactor the Application Delegate

368 Views Asked by At

I am a beginner to Obj-C and Xcode 4 and I am currently going through the "Your First Mac Application" on the Mac Dev website. I have managed to get through the main part but I'm struggling on the "Refactor the Application Delegate" section.

I have created a new class (to use as a controller), added an object set to this new class, made the connections from the class to the slider, mute button and textfield, and I have connected the new class object to the app delegate interface file.

Unfortunately an instance of the track class is never created, and therefore the program doesn't work, as the awakeFromNib function never gets called. I have tried placing it in both the app delegate file and the new controller class.

Where am I going wrong???

2

There are 2 best solutions below

0
On

I had the same issue while trying out the tutorial and found out the problem was with my implementation of awakeFromNib

Wrong Code:

- (void)awakeFromNib:(NSNotification *)aNotification

Right Code

- (void)awakeFromNib

There should be no argument passing the implementation of awakeFromNib.

1
On

You have to either create an instance of your new class in IB, or you need to create it programmatically in your AppDelegate object (usually in init or awakeFromNib). You need to have a pointer to that object in your AppDelegate. If you create the new object in IB, you connect it to the Track* pointer in IB. If you do it in code, it's something like:

in .h file:

TrackClass *track;

in .m file:

track = [[Track alloc] init];

Which did you do?