working on a challenge from a book on Cocoa programming for Mac os x, by Hillegas. The challenge is to write an application that takes what the user types and copies the string, and then displays the string and the number of characters in the string. i started a new project in x-code and then in interface builder i dragged a button and a text field from the library window to my window for my application. i also dragged a label to my application window. That was the easy part. I want to have the label when my application runs, display three question marks. and then display a string which the user has entered into the textField, along with the string i want my application to display the length of the string.
can i use printf or should i use NSLog, just trying to complete a challenge.
i have an older book on objective-c i tried writing a simple program. I wanted the program to initially be a command line tool. I thought if i can get my computer to count the number of characters in a string, in a program that is a command line tool, that i could take what i learned from writing the program and apply it to the challenge from the Hillegas book. I don't know if that is the best way to solve the challenge? So my question is how do i count the number of characters in a string. In the older book on objective-c there is a program in it that has the following code snippet:
what is length in these lines, is it a method.
in the Hillegas book:
how do i get what the user types in, and copy it, and or count it.
How would you teach someone to complete this challenge? To paraphrase Denzel Washington "explain how i would get started writing this application as if i were a six year old." I would accept help with the x-code project as an application or as a command line tool.
any help would be appreciated.
can i use printf or should i use NSLog, just trying to complete a challenge.
i have an older book on objective-c i tried writing a simple program. I wanted the program to initially be a command line tool. I thought if i can get my computer to count the number of characters in a string, in a program that is a command line tool, that i could take what i learned from writing the program and apply it to the challenge from the Hillegas book. I don't know if that is the best way to solve the challenge? So my question is how do i count the number of characters in a string. In the older book on objective-c there is a program in it that has the following code snippet:
Code:
NSString *str1 = @"This is string A" ...
//count the number of characters
printf ("Length of str1: %i\n", [str1 length]);
what is length in these lines, is it a method.
in the Hillegas book:
Code:
"You will also find it useful to know about the following methods of the class NSString:
- (int)length"
how do i get what the user types in, and copy it, and or count it.
How would you teach someone to complete this challenge? To paraphrase Denzel Washington "explain how i would get started writing this application as if i were a six year old." I would accept help with the x-code project as an application or as a command line tool.
any help would be appreciated.