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 > Cocoa labels

Cocoa labels
Thread Tools
Fresh-Faced Recruit
Join Date: Aug 2006
Location: London, UK
Status: Offline
Reply With Quote
Dec 4, 2007, 11:42 AM
 
Hi,

I'm really stuck on how to set the text of a label programatically.

I've tried using:

[text setString: @"Hi"];

text being the name of the IBOutlet variable.

How can I do this?

Thanks
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 4, 2007, 12:43 PM
 
Assuming you're talking about an NSTextField (which are used for draggable labels in IB), it doesn't respond to setString: (which is an NSTextView and NSMutableString method, IIRC). It responds to setStringValue: (from NSControl).
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Jul 2002
Status: Offline
Reply With Quote
Dec 5, 2007, 02:45 PM
 
If you had declared the IBOutlet as a NSTextField, the compiler should have warned you about NSTextField not having a setString: method. So you should definitely set your types explicitly whenever you can.
     
   
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 09:35 AM.
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