What I do: I'm writing my first objective-c-software and I begun to write the code. First, it was thought o be a command-line-tool, which also was the type of project, I initially chose. After finishing, I added a new „Application Xib“-File, named „BedienOberflaeche.xib“ and created a GUI.
My problem: I try to get a response by clicking a button in my new GUI, but I get no response.
My research history: severel issues like creating buttons, connecting buttons with the object instance and something like „NSButton doesn't respond“. I couldn't find an answer, yet.
Relevance for others: This issue is relevant for all those, wo are creating their first objective-c-application and adding a GUI on it. I think, it is pretty basic.
My work platform: I'm working on Mac OS X 10.6.8 Snow Leopard and Xcode 3.2.6 on a MacBook 2,1. I found in the xib-file of the GUI the following:
Ed$ grep GuiPage FotobuchErsteller_0/BedienOberflaeche.xib
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10K549</string>
<string key="IBDocument.InterfaceBuilderVersion">851</string>
<string key="IBDocument.AppKitVersion">1038.36</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
I already tried the following: My GUI contains one button, named „Selbsttest“. The graphic representation of the file „BedienOberflaeche.xib“ contains an entry, looking like a half-transparent blue box representing an object instance as subclass of „GuiPage.m“ after the connected class „GuiPage.m“ (no gap), which I configured under „Inspector“ → „Gui Page Identity“ (with gap) → „Class Identity“ → „Class = GuiPage“. The class „GuiPage.m“ contains code to execute after clicking the button. The object has a connection between the method „fuehreSelbsttestAus:“ and the entry „Push Button (Selbsttest)“, found at Inspector → „Gui Page Connections“ → „Recieved Actions“. „fuehreSelbsttestAus:“ is the name of a method, that should be executed by clicking the button. Besides that, I didn't perform any other configurations for the object.
The button itself shows a connection beween „fuehreSelbsttestAus:“ and the object „Gui Page“ under Inspector → „Button Connections“ → „Sent Actions“. Besides its title „Selbsttest“ in Inspector → „Button Attributes“ → „Title“, I didn't perform any further configuration in the other button concerning sections „Button Effects“, „Button Size“, „Button bindings“ and „Button Identity“ of the inspector.
The Method „fuehreSelbsttestAus“ can be found in the Class „GuiPage.m“:
#import "GuiPage.h"
@implementation GuiPage
//[...]
#pragma mark Methoden
-(IBAction)fuehreSelbsttestAus:(id)sender{
NSLog(@"Der Knopf zum ausfuehren des Selbsttests wurde gedrueckt.");
}
It should reproduce simple logging entries. I tried to run the GUI by starting „File“ → „Simulate Interface“ in the Interface Builder, which showed me a simulation of the GUI, but however, I can't see any logging after clicking the button „Selbsttest“.
I checked, whether there is a „GuiPage“ and a „Selbsttest“-button-entry mentioned in the .xib-file:
Edo$ grep GuiPage FotobuchErsteller_0/BedienOberflaeche.xib
<string key="NSClassName">GuiPage</string>
<string key="objectName">GuiPage</string>
<string key="className">GuiPage</string>
<string key="minorKey">GuiPage.h</string>
and
Edo$ grep Selbsttest FotobuchErsteller_0/BedienOberflaeche.xib
<string key="NSContents">Selbsttest</string>
<string key="label">fuehreSelbsttestAus:</string>
<string key="NS.key.0">fuehreSelbsttestAus:</string>
<string key="NS.key.0">fuehreSelbsttestAus:</string>
<string key="name">fuehreSelbsttestAus:</string>
The connection between the button and the object is mentioned there. Therefore I wonder, what can I do further to execute written code in the Method „fuehreSelbsttestAus“ by clicking the button. Has anybody an idea? I'd really appreciate any help.
The solution, as suggested, is to create an cocoa application and to transfer all the source code files in it. Obviously, the command line application type is not the right project type to be extent to an gui-based application.