小编Ric*_*edt的帖子

Swift函数中的默认可选参数

当我设置firstThing为默认值时,nil这将起作用,没有默认值nil我得到一个错误,即调用函数时有一个缺少的参数.

通过键入Int?我认为它使其成为可选的默认值nil,我是对的吗?如果是这样的话,为什么没有它= nil呢?

func test(firstThing: Int? = nil) {
    if firstThing != nil {
        print(firstThing!)
    }
    print("done")
}
test()
Run Code Online (Sandbox Code Playgroud)

function optional swift

89
推荐指数
5
解决办法
8万
查看次数

React native NSPOSIXErrorDomain Code = 61"Connection refused"

我正在尝试使用脱机捆绑包将React Native应用程序部署到我的手机上.我之前没有为ios开发过,也不确定在哪里查找此错误.是的,我的应用程序名为"ReactNativeTest",我不知道Xcode会创建一个名为"ReactNativeTestTests"的文件夹哈哈.

那我应该从哪里开始这个问题呢?

2015-11-14 15:58:36.637 [error][tid:com.facebook.React.WebSocketExecutor][RCTWebSocketExecutor.m:127] 

WebSocket connection failed with error Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"
2015-11-14 15:58:36.686 reactNativeTest[5240:2439923] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x136f60520 V:|-(20)-[UIInputSetContainerView:0x136f5f8b0]   (Names: '|':UITextEffectsWindow:0x136f5ece0 )>",
    "<NSLayoutConstraint:0x136e2fc60 'UIInputWindowController-top' V:|-(0)-[UIInputSetContainerView:0x136f5f8b0]   (Names: …
Run Code Online (Sandbox Code Playgroud)

iphone ios reactjs react-native

7
推荐指数
1
解决办法
8148
查看次数

javascript排序函数排序时不应该

function longest(arr) {
  return arr.sort( (a,b) => {
    return a.length - b.length;
  });
}
var res = longest(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k','l']);
console.log(res); // -> [ 'f', 'a', 'c', 'd', 'e', 'b', 'g', 'h', 'i', 'k', 'l' ]
Run Code Online (Sandbox Code Playgroud)

如何以这种奇怪的方式对这个函数的返回进行排序?据我了解,它根本不应该改变阵列.

我对么?

javascript sorting

3
推荐指数
1
解决办法
82
查看次数

标签 统计

function ×1

ios ×1

iphone ×1

javascript ×1

optional ×1

react-native ×1

reactjs ×1

sorting ×1

swift ×1