Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
I am new to IOS/Objective C but programming in C++ / C / Java and a dozen other languages for decades...

I built the HelloWorld program on the IOS site - no problem.

Now I am trying to work my way through the samples in "iPhone SDK development".

I have a class MovieViewController

in the header file
Code:
#import <UIKit/UIKit.h>

@interface MovieViewController : UIViewController {
	UILabel	*titleLabel;
}

@property(nonatomic,retain) IBOutlet UILabel *titleLabel;

- (void) (IBAction)edit;
@end

BUT - I added a button in IB to the MovieViewController xib file and Ctrl Click the file owner and neither the property nor the action show up so obviously I cannot link the action to the button.

I only added the property to see if it would show up after having failed to get the action.

I have tried multiple variations of the action e.g.
Code:
- (IBAction) edit;
- (IBAction) edit: (id) sender;
but nothing ever shows up in IB.

Am I really doing something stupid here?

Help appreciated.
Dave.
 

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
'fraid so.

I hit that problem the first time round.

I added a method implementation and built it, closed the project and re-opened it all just in case...

No luck.
 

cnstoll

macrumors 6502
Aug 29, 2010
254
0
I am not completely sure if this is required or not, but usually when I am linking an action and a button in IB, I define the UIButton as an IBOutlet in the header as well. I don't know if it's a requirement or not, but I suppose it's worth a shot. If nothing else, then you can modify the button parameters in code if you need to later.

Aside from that, when you say "control clicking" does that mean you're actually trying to control click on the button or file's owner in IB and drag from one to the other? I'm not in front of my computer so I can't verify and therefore could be mistaken, but for what it's worth I believe the list of available IB properties only shows up when you've dragged and created a line to your destination.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
I am not completely sure if this is required or not, but usually when I am linking an action and a button in IB, I define the UIButton as an IBOutlet in the header as well. I don't know if it's a requirement or not, but I suppose it's worth a shot. If nothing else, then you can modify the button parameters in code if you need to later.
Just FYI: it's not required.

I added a method implementation and built it, closed the project and re-opened it all just in case...

No luck.
And no warnings from the build?

P.S. The code looks fine to me, other than the:
- (void) (IBAction)edit;
which has two return types.
 
Last edited:

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
Aside from that, when you say "control clicking" does that mean you're actually trying to control click on the button or file's owner in IB and drag from one to the other?

Ctrl-Click of File Owner is supposed to pop up a list of outlets and actions.
It is not happening in this case.

Dragging the Touch Up Inside method to the File Owner - the File Owner does not cause the File Owner to get highlighted in the usual way and the edit method does not pop up.

EDIT:

I originally tried without the (void) and the result was the same.

No errors or warnings from the build.

Run it and the button behaves like a button (turns a friendly blue).
 
Last edited by a moderator:

cnstoll

macrumors 6502
Aug 29, 2010
254
0
In the inspector, double check to make sure the file's owner is actually pointed to MovieViewController class. I believe it's on the tab furthest to the right on the inspector.
 

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
Another project has the same project with outlets

I moved on to the next example and have a similar problem with the outlets...

Code:
#import <UIKit/UIKit.h>
#import "Movie.h"
#import "MovieEditorViewController.h"


@interface RootViewController : UITableViewController {
	NSMutableArray	*moviesArray;
	MovieEditorViewController * movieEditor;
}

@property (nonatomic, retain) IBOutlet MovieEditorViewController * movieEditor;

@end

yet when, in RootViewController.xib, I right click the file owner, movieEditor does not appear as an available outlet - nor can I drag anything onto it to connect to it.

I am sure I am doing something stupid (I am using an IOS 3 book to program IOS 4) - anybody had trouble like this before?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
cntl-click (and release) or right-click (and release) on File's Owner should show a black HUD window with the outlets etc. in it. This should happen regardless of anything else (I can think of). You get this HUD window for any object in the nib list.

Make sure your View mode is list view.

Is the Type for File's Owner correct?

In the bottom left corner of the nib window is an led icon and the name of the project. The led should be green, but it can also be yellow or grey to indicate errors. What color is it?

The code you show in response #8 looks syntactically valid. However, one doesn't usually have IBOutlets that are view controllers. Is that really correct? Is the view controller inside the nib?
 

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
cntl-click (and release) or right-click (and release) on File's Owner should show a black HUD window with the outlets etc. in it. This should happen regardless of anything else (I can think of). You get this HUD window for any object in the nib list.
Make sure your View mode is list view.

Is the Type for File's Owner correct?

In the bottom left corner of the nib window is an led icon and the name of the project. The led should be green, but it can also be yellow or grey to indicate errors. What color is it?

The code you show in response #8 looks syntactically valid. However, one doesn't usually have IBOutlets that are view controllers. Is that really correct? Is the view controller inside the nib?

The HUD does not show this property.

The file's owner is RootViewController.

The LED is Grey- the label is MovieTable.xcodeproj and the message is "There is no XCode project associated with this document. Interface Builder will synchronize with open XCode projects that contain this document.

The book indicates that I should have a view controller here. I believe that this is done to associate another class/screen with the view/edit function of the table view.

A view controller has been added to the NIB - I had to set the class by typing it the name did not appear in the list.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
OK, given that error and the grey led then the problem is that your nib isn't associated with a project correctly.

Is the nib in a project and is the project open in Xcode? If not then make it so. If it is in a project then how do you open the nib? Double-click in the project window in Xcode or something else?

I think the problem is just that you don't have the project open in Xcode. I just noticed that if you click the project name next to the led in the nib window then Xcode opens the project.
 

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
OK, given that error and the grey led then the problem is that your nib isn't associated with a project correctly.

Is the nib in a project and is the project open in Xcode? If not then make it so. If it is in a project then how do you open the nib? Double-click in the project window in Xcode or something else?

I think the problem is just that you don't have the project open in Xcode. I just noticed that if you click the project name next to the led in the nib window then Xcode opens the project.

That's the crazy bit. I open the nib by double click inside the open project.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
If the project really is open in Xcode and really has the nib in it then can you confirm that the nib is in the target? Get Info on the nib file and check that it's in the target.

Another possibility is that there is a space or other "funny" character in the full path to the project. This can sometimes cause problems.

What does happen if you click the name of the project at the bottom of the nib window?
 

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
If the project really is open in Xcode and really has the nib in it then can you confirm that the nib is in the target? Get Info on the nib file and check that it's in the target.

Another possibility is that there is a space or other "funny" character in the full path to the project. This can sometimes cause problems.

What does happen if you click the name of the project at the bottom of the nib window?

OK - I just reopened the project and it looks OK now :(

I have a suspicion - the previous time I clicked from the resources view, this time I clicked from the project view (all files on display). I will check and report back.
 

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
OK - I just reopened the project and it looks OK now :(

I have a suspicion - the previous time I clicked from the resources view, this time I clicked from the project view (all files on display). I will check and report back.

So much for foolish optimism.

Yesterday lunch time I opened the project and all was well. I made NO changes.

Last night and this morning I opened it and the button at the bottom is grey again and I cannot see the new outlets.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
I haven't run into this kind of problem but there have been various reports of similar problems on the Apple iPhone forum.

Are there any funny characters, like space or accented characters, in the full path to the project? Is the nib file inside the project folder? Have you changed the name of the project after it was created?

Choose Clear Menu in the Xcode Recent Projects menu.

What happens when you click the name of the project in the nib window?
 

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
I haven't run into this kind of problem but there have been various reports of similar problems on the Apple iPhone forum.

Are there any funny characters, like space or accented characters, in the full path to the project? Is the nib file inside the project folder? Have you changed the name of the project after it was created?

Choose Clear Menu in the Xcode Recent Projects menu.

What happens when you click the name of the project in the nib window?

Funny Characters - only me :rolleyes:

I came across this which seems to work - do not open from recent projects, instead, open by double clicking the project file. Seems OK on first try.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.