Lets say that I have an NSString that I want to give it a value.
Am I obliged to use the standard input functions that C has? My problem is that NSString doesn't have any limitations as to how many characters I will give. But all plain C functions do have this limitation, so I must know in advance the number of characters I must declare the array which will hold my NSString to hold. So I have to do it this way:
Is there any other way, so that I am not forced to declare how many characters I will read in advance?
I suppose I could do this using Objective C++ (using the string class of the STL and then converting the string class to plain character array and inserting it to the string) but I am searching for a plain Obj-C style input.
Any ideas? Sorry if that's a newbie's question, I am just learning Obj-C, and I come from a strong C++ experience.
Am I obliged to use the standard input functions that C has? My problem is that NSString doesn't have any limitations as to how many characters I will give. But all plain C functions do have this limitation, so I must know in advance the number of characters I must declare the array which will hold my NSString to hold. So I have to do it this way:
Code:
char p[30];
scanf("%s",p);
NSString *test = [[NSString alloc] initWithCString: p];
I suppose I could do this using Objective C++ (using the string class of the STL and then converting the string class to plain character array and inserting it to the string) but I am searching for a plain Obj-C style input.
Any ideas? Sorry if that's a newbie's question, I am just learning Obj-C, and I come from a strong C++ experience.