UIWebView를 사용하여 사용자 지정 브라우저를 작성하고 있습니다.Swift에서 stringWithFormat을 사용하여 url 앞에 http : //를 붙이는 방법
사용 사례 : 사용자가 주소 표시 줄에 "www.abc.com"을 입력합니다. 오류가 아래의 발생 :
Error Domain=WebKitErrorDomain Code=102 "Frame load interrupted" UserInfo=0x19860770 {NSErrorFailingURLKey=file://www.abc.com, NSErrorFailingURLStringKey=file://www.abc.com, NSLocalizedDescription=Frame load interrupted}
이유 : URL이 앞에 추가 할 필요에 "http : //"
내가있는 NSString의stringWithFormat
방법을 사용하고 싶습니다,하지만 난을 얻을 수없는 것 올바른 구문. Objective-C에서 우리는 다음과 같은 것을 가지고있다.
NSString* modifiedURLString = [NSString stringWithFormat:@"http://%@", urlString];
스위프트에서는 방법이 없습니다.
var modifiedURLString: String = String(`stringWithFormat not here?!...`)
난 후 신속한와 목표 C를 혼합하려고 :
VAR의 modifiedURLString :있는 NSString =있는 NSString stringWithFormat not here?!...
그럼 I 직선해서 오브젝티브 C 시도 :
는 NSString * modifiedURLString = [NSString stringWithFormat : @ "http : //", urlString];
도움 주셔서 감사합니다. 감사합니다, 키스
의도 된 http : // "접미사"가 작동하지 않았습니까? – Tommy
이 자습서를 사용하고있었습니다. "사용자 입력 수정"아래를보십시오 http://iosdeveloperzone.com/2011/05/22/tutorial-building-a-web-browser-with-uiwebview-part-3/ – kmiklas