Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSTextField, Need a Clue.

NSTextField, Need a Clue.
Thread Tools
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
May 28, 2001, 03:30 PM
 
After some success with the tutorials I decided to mess around a bit and was quickly stuck with NSTextField -rather heartbreaking, since this is seems to pretty easy. Here is the scenario.

1. Press a button
2. The button sends a message to a controler object
3. controller object sends a message to a "Message Text" element to
change its title to "Running".

Simple enough right? Here is the method implementation. Note that "MessageArea" is of "IBOutlet id" type and points to the Message Text element.

- (IBAction)start id)sender
{

[ MessageArea setStringValue:@"Running" ];

... some other code goes below here, which I know it's not broken

}

Well, this drives the compiler bananas! It returns an error for all the code that follows and no error for the setStringValue call. Weird ah? If I comment the suspect line above, all compiles perfectly. Any ideas?



[This message has been edited by DaGuy (edited 05-28-2001).]
iMac 17" G4 800MHZ & 768 SDRAM
     
Dedicated MacNNer
Join Date: Apr 2001
Location: San Francisco, USA
Status: Offline
Reply With Quote
May 28, 2001, 10:30 PM
 
this drives the compiler bananas! It returns an error for all the code that follows and no error for the setStringValue call. Weird ah? If I comment the suspect line above, all compiles perfectly.

Make sure all your variable declarations come first.

- (IBAction)startid)sender
{

// Local variable declarations
// int i = 0;
// etc.

[ MessageArea setStringValue:@"Running" ];

// more code statements

}
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
May 28, 2001, 10:54 PM
 
Thanks a whole bunch! I followed your tip and it worked just fine.

I have to some how curb my Java schooling, that C in objective-C is to be taken quite seriously.

iMac 17" G4 800MHZ & 768 SDRAM
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
May 29, 2001, 01:39 PM
 
Actually, you can put declarations anywhere in C99... I just want Apple to start putting support for it into their compiler
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
May 29, 2001, 01:55 PM
 
That will happen whenever Apple moves to a gcc that has support for C99. If gcc 3.0 does have full support for C99, then it will almost certainly be happening, though not in the near future. gcc 2.95 (which Apple's cc is currently based off of) does not have much C99 support I guess.
     
Junior Member
Join Date: Mar 2001
Status: Offline
Reply With Quote
May 30, 2001, 11:00 PM
 
Apple's forthcoming Objective-C++ compiler would also allow variables to be declared at any point in a code block.

-Peter
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:15 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2