我在使用文本字段的值并将其写入文件的可可应用程序时遇到问题。文件路径使用 stringWithFormat: 组合 2 个字符串。由于某种原因,它不会创建文件并且控制台什么也没说。这是我的代码:
//Get the values of the text field
NSString *fileName = [fileNameTextField stringValue];
NSString *username = [usernameTextField stringValue];
//Use stringWithFormat: to create the file path
NSString *filePath = [NSString stringWithFormat:@"~/Library/Application Support/Test/%@.txt", fileName];
//Write the username to filePath
[username writeToFile:filePath atomically:YES];
谢谢你的帮助