连接unwrapped可选和字符串

时间:2017-02-10 09:39:12

标签: xcode swift3

.item-btn-grp {
    display:inline-block;
    float: right;
    height: 40px;
    border-left: 1px solid #a1a0a0;
    -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1s;
    -moz-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1s;
    -o-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1s;
    transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1s;
    right: 0;
}

.item-btn-grp.ng-hide {
  right: -50px;
  opacity:0;
  padding:0 10px;
}


<div id="tasks-list">
    <li class="task-item"  ng-mouseover="myValue = true" ng-mouseleave="myValue = false">
        Do this And then that
        <div class='item-btn-grp' ng-show="myValue" >
            <button class="item-btn-ok"><span class="glyphicon glyphicon-ok"></span></button>
            <button class="item-btn-remove"><span class="glyphicon glyphicon-remove"></span></button>
        </div>
    </li>
    <li class="task-item"  ng-mouseover="myValue = true" ng-mouseleave="myValue = false">
        Do this And then that
        <div class='item-btn-grp' ng-show="myValue" >
            <button class="item-btn-ok"><span class="glyphicon glyphicon-ok"></span></button>
            <button class="item-btn-remove"><span class="glyphicon glyphicon-remove"></span></button>
        </div>
    </li>
</div>

我从json文件获得了baseURL和路径。现在webview应该打开新的url(baseURL +路径)。我不知道如何创建新的url,因为baseURL是字符串的类型,路径是unwrapped optional.I& #39; m getting error:参数标签字符串与let url = URL(String:urlString)中的任何可用重载都不匹配

1 个答案:

答案 0 :(得分:1)

假设baseURLpath的类型为String

let baseURL = "http://10.150.160.170"
let path = "/welcome-page"
let urlString = baseURL + path
let url = URL(string: urlString)
let requestObj = URLRequest(url: url!)