Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 21, 2013, 11:11 AM   #1
djjasonsa
macrumors newbie
 
Join Date: Jun 2012
XCode - Cocoa-applescript question

Hi All,

I am trying to create a simple Cocoa-applescript, however I am having issues with getting a Text Field or Label to display the output from a shell command.

I know this probably basic stuff but an help would be most grateful

Thanks
djjasonsa is offline   0 Reply With Quote
Old Feb 21, 2013, 12:32 PM   #2
Red Menace
macrumors 6502
 
Join Date: May 2011
Location: Littleton, Colorado, USA
Is this an Xcode or AppleScript Editor project? Usually you would get the result from your shell script and put it into the text field using its setStringValue: method, although bindings can also be used. What have you done so far?
__________________
MacBook Pro / OS X Yosemite (10.10) / Xcode 6.1 / RubyMotion FTW
Red Menace is offline   0 Reply With Quote
Old Feb 21, 2013, 12:50 PM   #3
djjasonsa
Thread Starter
macrumors newbie
 
Join Date: Jun 2012
Thank you very much for the quick response.

Last edited by djjasonsa; Feb 22, 2013 at 12:08 PM.
djjasonsa is offline   0 Reply With Quote
Old Feb 21, 2013, 04:50 PM   #4
Ap0ks
macrumors regular
 
Join Date: Aug 2008
Location: Cambridge, UK
The text field you're trying to populate, have you changed it's behaviour from editable to selectable or none?

Your posted code works fine for me if the text field behaviour is set to editable. To make it work when the text field behaviour is set to selectable or none I had to put your code into the awakeFromNib method rather than an IBAction method, like so:
Code:
on awakeFromNib()
        set ipAddress to (do shell script "ifconfig | grep -B 2 active | grep -E \"inet \" | awk {'print $2'}")
        label's setStringValue_(ipAddress)
    end awakeFromNib
Ap0ks is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Convert Applescript to Xcode Project omgitssum1 Mac Programming 3 Feb 26, 2014 03:57 AM
Xcode or cocoa? Pajamaxllama iPhone/iPad Programming 9 Oct 22, 2013 10:01 AM
How to show/hide objects in Cocoa Applescript application sjmonty99 Mac Programming 3 Aug 6, 2012 12:02 PM
COMBOBOX populate from text file (cocoa applescript) nicoboss Mac Programming 4 Jun 29, 2012 02:36 PM

Forum Jump

All times are GMT -5. The time now is 05:19 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC