Я делаю учебник по Какао, где мне нужно подсчитать символы в поле, а затем вывести что-то вроде 'the_string_i_am_count', содержащее 21 символ.
Мне удалось получить строку, сосчитать ее и вывестисчет, но я не знаю, как вывести счет вместе со строкой и другой информацией.
Как мне это сделать?
-(IBAction)countCharacters:(id)sender
{
//i had to connect this to the class also to make it get the value.
//NSString *string = [inputField stringValue];
//get the number of chars
NSUInteger length = [[inputField stringValue] length];
[outputField setIntValue:length]; //string];
//[outputField setStringValue: @"'s' has %d characters.", string, length];
}
Полу рабочий код:
-(IBAction)countCharacters:(id)sender
{
//i had to connect this to the class also to make it get the value.
NSString *string = [inputField stringValue];
//get the number of chars
NSUInteger length = [[inputField stringValue] length];
[outputField setStringValue:[NSString stringWithFormat:@"'%s' has %d characters.", string, length]];
}