There is an object:

NSTextField *outText = "Текст"; 

How to check the second line element as it was in C ++:

 if(outText[1] == 'е'){ ... 

    1 answer 1

    You can get to the second character in the following way (I write everything in one line, although I need to break it for readability and to check that there really is a second character in the line):

     if ([[[outText stringValue] substringWithRange:NSMakeRange(1,1)] isEqualToString:@"e"]) { // ... } 

    I did not check it myself, but it should work.

    • maybe [outText text]? - Anastasia
    • This is NSTextField, not UITextField, a slightly different story ... - Stanislav Pankevich
    • It works. Here, as I understood it, at first the line is reduced to the range (1, 1), and then this line is compared with "e". Is it all so difficult, considering even the fact that we are moving to the NSString class? Is there no other way for this class? Or does this seem to me as a novice programmer in Objective-C? - Adam
    • I found the characterAtIndex method in the NSString class, which allows you to read a character by index. Now you can simplify the code like this: if ([outText stringValue] characterAtIndex: 1 == 'e']) {// ...} - Adam
    • I specifically did not work with characterAtIndex myself and wrote a quick reply. Of course, characterAtIndex , in short. That's right. - Stanislav Pankevich