Reading NSString from Command Prompt

Discussion in 'Mac Programming' started by Kelmon, May 20, 2007.

  1. Kelmon macrumors 6502a

    Kelmon

    Joined:
    Mar 28, 2005
    Location:
    United Kingdom
    #1
    Stupid question but I'm trying to develop a simple command-line based application that can be wrapped by a Cocoa GUI. My problem is reading in the input from the command-line and converting this input to an instance of NSString. The following is basically what I have so far:

    Code:
    char seed[13];
    NSString *seedString;
    int nScanned;
    	
    do {
    	nScanned = scanf("%s", &seed);
    	if (nScanned == 1) {
    		printf("Input has been read successfully: %s\n", seed);
    		seedString = [[NSString alloc] initWithCString:seed];
    		int stringLength = [seedString length];
    		NSLog("Input as an instance of NSString: %@ with length %i\n", seedString, stringLength);
    	}
    } while (nScanned == 1);
    The initial output looks good. However, the NSLog line is generating warnings in the compiler that "argument 1 of NSLog from incompatible pointer type" and the rest of the output is nonsense. Unfortunately, I'm having difficulty finding much information on getting input from the command-line so I'm hoping someone else has a bit more experience with this.
     
  2. Kelmon thread starter macrumors 6502a

    Kelmon

    Joined:
    Mar 28, 2005
    Location:
    United Kingdom
    #3
    Oh, brother, how did I miss that one?

    Thanks for not taking the piss. Much appreciated...
     

Share This Page