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 > Is there an NSInput (sort of like NSLog, but for input)???

Is there an NSInput (sort of like NSLog, but for input)???
Thread Tools
Junior Member
Join Date: Aug 2002
Location: Northeastern NV, USA
Status: Offline
Reply With Quote
Nov 10, 2002, 12:33 PM
 
OK...

This may seem like a simple question but I'm going to go ahead and ask it...

Is there something similar to scanf in the NS world to input an NSString from the command line? Similar to how NSLog is analagous to printf ? Or do you just use scanf to input a C string, and then use initWithCString to pump your C string into an NSString? Makes sense to me, but was wondering if there was something available in the NS arena for accepting simple string input into a program during run-time.

In case your wondering what I would use this for, the answer is that I don't really have a practical use. I just wanted to know!

Thanks!
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Nov 10, 2002, 03:04 PM
 
Originally posted by yeslekmc:
Is there something similar to scanf in the NS world to input an NSString from the command line? Similar to how NSLog is analagous to printf ? Or do you just use scanf to input a C string, and then use initWithCString to pump your C string into an NSString? Makes sense to me, but was wondering if there was something available in the NS arena for accepting simple string input into a program during run-time.
Nope. The point of NSLog isn't really to give you a function that uses a string object instead of a C string. That's just part of its behavior. NSLog is there for exactly what it says--logging. I can't imagine what an equivalent scanning function would do.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Nov 10, 2002, 05:02 PM
 
Originally posted by Chuckit:

Nope. The point of NSLog isn't really to give you a function that uses a string object instead of a C string. That's just part of its behavior. NSLog is there for exactly what it says--logging. I can't imagine what an equivalent scanning function would do.
Use scanf, but return NSString's?

Matt
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Nov 11, 2002, 12:36 AM
 
Originally posted by Ghoser777:


Use scanf, but return NSString's?
Nope. The only thing that function would have in common with NSLog is its use of NSStrings, which is something it also has in common with a hundred other methods. That was my point.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Junior Member
Join Date: Aug 2002
Location: Northeastern NV, USA
Status: Offline
Reply With Quote
Nov 11, 2002, 09:00 AM
 
I guess my real question from the beginning should have been this:

Is there a way to input an NSString straight from the command line?

It's trivial to convert a C String into an NSString after input, but I was just wondering if I had overlooked all of the classes and objects and missed a method that would allow you to do this directly.

Thanks again!
     
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Nov 11, 2002, 09:30 PM
 
Originally posted by yeslekmc:
I guess my real question from the beginning should have been this:

Is there a way to input an NSString straight from the command line?

It's trivial to convert a C String into an NSString after input, but I was just wondering if I had overlooked all of the classes and objects and missed a method that would allow you to do this directly.

Thanks again!
I see no reason why scanf itself would not work. The real question then would be where does it take it's input from. Usually, it is from standard in, you need to change it to whatever it is you want to use for input. In this case, you probably want to have your application create a scroll view or text view and take it's input from from there, for example doing a scanf on each line whenever the return key is pressed (you can set a delegate to check for changed text).

Is this what you mean?
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Nov 12, 2002, 04:26 PM
 
Well, since it's trivial to read a C string from stdin and put it in an NSString, it's also trivial to write a function of your own which does just that. Then it'll be even more trivial to input NSStrings because you'll only have to call your MYInputString() function.
Rick Roe
icons.cx | weblog
     
   
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 06:19 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