线程1:在JSONSerialization中发出SIGABRT信号

时间:2018-04-12 06:00:31

标签: ios swift nsjsonserialization jsonserializer

我正在制作array&把它放进JSONSerialization &安培; compliler以SIGABRT失败。

    let array = [1,2,3,4,5,6]
    let arraySlice = array[1...3]
    print(String(data: try! JSONSerialization.data(withJSONObject: arraySlice, options: .prettyPrinted), encoding: .utf8 )!)
  

线程1:信号SIGABRT

如何序列化数组切片?

1 个答案:

答案 0 :(得分:2)

@TypeConverter public static Size getSize(int numeral){ for(Size s : values()){ if(s.numeral == numeral){ return s; } } return null; } @TypeConverter public static Integer getSizeInt(Size size){ return size.numeral; } 无效JSONSerialization,您首先需要将其转换为ArraySlice

Array