Strings
Strings
- Subject: Strings
- From: Daniel Byer <email@hidden>
- Date: Tue, 12 Feb 2002 18:12:15 -0600
I'm using Project Builder to develop a Cocoa Objective-C application.
What I'm trying to do is parse a string. I have two text boxes, and a
button.
When the button is clicked, it reads the string from inputField into a
character array, loops through the array switching all the space (' ')
characters to newline ('\n') characters, and places the new string to
parsedField.
I'm using simple source code as follows:
char input[258], output[258], *increment;
int index;
*input = [inputField stringValue]; //warning #1: assignment makes integer
//from pointer without a cast
if ( strlen( input ) <= 256 ) {
increment = &input[0];
index = 0;
while (*increment++) {
if ( input[index] != ' ' ) {
output[index] = input[index];
}
else {
output[index] = '\n';
}
index += 1;
}
output[index] = '\0';
[parsedField insertText:output]; //warning #2: passing arg 1 of
'insertText:'
//from incompatible pointer type
}
else {
[parsedField setStringValue:@"Error: input exceeded 256
characters."];
}
Now, I have no idea what I'm doing, since I'm very new to Objective-C. I
tried looking at the NSString classes, NSText classes, etc, but I didn't
find an answer. The application runs, but when I enter a string in
inputField and click the parse button, it just beeps and does nothing as
far as I can tell. Any advice on how to fix this..?
Thanks in advance,
Daniel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.