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 > Objective-C: simple way to write to stdout?

Objective-C: simple way to write to stdout?
Thread Tools
hadocon
Mac Elite
Join Date: Oct 2001
Location: Internet
Status: Offline
Reply With Quote
Dec 6, 2006, 01:13 PM
 
Hey, y'all

I have an x-code GUI project that reads telemetry from a bluetooth device. I want to be able to write this to stdout (terminal).

There's gotta be a very simple way to do this I am guessing. I'm a complete OBJ-C newb, so... well... I'm learning from this post, no?

Anyone want to learn me?
20+ year MacNN forum member. MacBook Air 11" 1.6Ghz 4GB 128GB Backlit Keyboard, 4S, iPad Mini
     
black bear theory
Grizzled Veteran
Join Date: Aug 2005
Location: fairbanks AK
Status: Offline
Reply With Quote
Dec 6, 2006, 01:31 PM
 
i think your requirements for your program are a little skewed. you want a GUI app that displays output to a terminal? that kind of defeats the purpose of having a GUI, don't you think?

a NSLog() call containing the information you want would write the info to the system log which you could then read in Console.app. or, more likely what you want, you could just append/overwrite new output into a NSTextView that you place in your GUI, so the output can be seen/updated when you interact with the other controls you have for your app.

hope that helps some.
Earth First! we'll mine the other planets later.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 6, 2006, 02:10 PM
 
You can write to stdout with printf(), just like in C. But like Black Bear Theory said, this seems kind of odd. GUI apps don't normally have a controlling terminal (hence them being GUI apps), so I don't think stdout goes anywhere.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
techtrucker
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Dec 6, 2006, 07:57 PM
 
Maybe just use a multi line text field?
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
     
hadocon  (op)
Mac Elite
Join Date: Oct 2001
Location: Internet
Status: Offline
Reply With Quote
Dec 7, 2006, 04:32 AM
 
I'm hacking existing software... It's a gui app that renders graphs of remote telemetry. I have the source code from another person. I want to be able to use the telemetry from this application in another application. If I can write the stream to stdout then I can pipe it into other shell apps, or shunt it across a network.

I know, this is an unorthodox request... just bear with me. I know that this is the functionality I need.

Looks like I will just use printf()...

Thanx for the help.
20+ year MacNN forum member. MacBook Air 11" 1.6Ghz 4GB 128GB Backlit Keyboard, 4S, iPad Mini
     
arcticmac
Dedicated MacNNer
Join Date: Apr 2004
Status: Offline
Reply With Quote
Dec 9, 2006, 10:47 AM
 
yeah... just use printf and then run the app from a shell instead of by double clicking in the finder.
FWIW, NSLog() basically takes an NSString instead of a standard c string, and prepends certain info like the program name, pid, and date, and appends a \n before writing it to std out.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 9, 2006, 01:57 PM
 
NSLog writes to stderr, actually, not stdout.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
arcticmac
Dedicated MacNNer
Join Date: Apr 2004
Status: Offline
Reply With Quote
Dec 9, 2006, 02:04 PM
 
ah... my bad
     
   
 
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
Top
Privacy Policy
All times are GMT -4. The time now is 09:31 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,