且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Xcode - 在webbrowser中打开一个URL

更新时间:2023-11-24 11:54:34

参见NSString + stringWithFormat :文档。



特别是,请查看格式化字符串对象示例和字符串格式说明符文档。



您需要将格式字符串更改为:



See the NSString +stringWithFormat: documentation.

In particular, look at the "Formatting String Objects" examples and the "String Format Specifiers" documentation.

You either need to change your format string to:

NSString *searchURL = [NSString stringWithFormat:@"https://www.google.com.au/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#hl=en&safe=off&tbo=d&sclient=psy-ab&q=%@", [_textbox1 stringValue]];





或者你可以说:





Or you could just say:

NSString *searchURL = @"https://www.google.com.au/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#hl=en&safe=off&tbo=d&sclient=psy-ab&q=";

searchURL = [searchURL stringByAppendingString: [_textbox1 stringValue]];