在 Kotlin 协程中,想要为当前线程创建一个引用并在以后使用它。
fun myFuncion(){
//save current Thread CoroutineScope
var currentCoroutineScope : CoroutineScope // <How to create?>
GlobalScope.launch {
//Do something 001
currentCoroutineScope .launch {
//Do something 002
}
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙解决这个问题吗?
我有这样的dict formate.我需要在字典的dict键中使用"quantity1"键对数组进行排序.
array: (
{
brand = Ryul;
productTitle = Any;
quantity = 1;
subBrand = "Ryul INJ";
type = Product;
dict = {
brand1 = Trol;
productTitle1 = Different;
quantity1 = 2;
subBrand1 = "";
type1 = Brand;
};
},
{
brand = Trol;
productTitle = Different;
quantity = 2;
subBrand = "";
type = Brand;
dict = {
brand1 = Trol;
productTitle1 = Different;
quantity1 = 2;
subBrand1 = "";
type1 = Brand;
};
}
)
Run Code Online (Sandbox Code Playgroud)
我用这个代码进行排序:
NSSortDescriptor …Run Code Online (Sandbox Code Playgroud)