 |
 |
Is there an NSInput (sort of like NSLog, but for input)???
|
 |
|
 |
|
Junior Member
Join Date: Aug 2002
Location: Northeastern NV, USA
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|