Shortcuts in Objective-C to concatenate NSStrings

前端 未结 30 3112
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 07:03

Are there any shortcuts to (stringByAppendingString:) string concatenation in Objective-C, or shortcuts for working with NSString in general?

30条回答
  •  天命终不由人
    2020-11-22 07:57

    For all Objective C lovers that need this in a UI-Test:

    -(void) clearTextField:(XCUIElement*) textField{
    
        NSString* currentInput = (NSString*) textField.value;
        NSMutableString* deleteString = [NSMutableString new];
    
        for(int i = 0; i < currentInput.length; ++i) {
            [deleteString appendString: [NSString stringWithFormat:@"%c", 8]];
        }
        [textField typeText:deleteString];
    }
    

提交回复
热议问题