i tried to get tempFileName from URLSession error and decode resumeData to a dictionary with below code
let resumeDictionary = try! PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [AnyHashable : Any]
resumeDictionary contains below string
[AnyHashable("$archiver"): NSKeyedArchiver, AnyHashable("$objects"): <__NSCFArray 0x2819140d0>( $null, { "$class" = "<CFKeyedArchiverUID 0x282221520 [0x1dc4981b8]>{value = 19}"; "NS.keys" = ( "<CFKeyedArchiverUID 0x282221320 [0x1dc4981b8]>{value = 2}", "<CFKeyedArchiverUID 0x282221340 [0x1dc4981b8]>{value = 3}", "<CFKeyedArchiverUID 0x282221360 [0x1dc4981b8]>{value = 4}", "<CFKeyedArchiverUID 0x282221380 [0x1dc4981b8]>{value = 5}", "<CFKeyedArchiverUID 0x2822213a0 [0x1dc4981b8]>{value = 6}", "<CFKeyedArchiverUID 0x2822213c0 [0x1dc4981b8]>{value = 7}", "<CFKeyedArchiverUID 0x2822213e0 [0x1dc4981b8]>{value = 8}", "<CFKeyedArchiverUID 0x282221400 [0x1dc4981b8]>{value = 9}" ); "NS.objects" = ( "<CFKeyedArchiverUID 0x282221420 [0x1dc4981b8]>{value = 10}", "<CFKeyedArchiverUID 0x282221440 [0x1dc4981b8]>{value = 12}", "<CFKeyedArchiverUID 0x282221460 [0x1dc4981b8]>{value = 13}", "<CFKeyedArchiverUID 0x282221480 [0x1dc4981b8]>{value = 14}", "<CFKeyedArchiverUID 0x2822214a0 [0x1dc4981b8]>{value = 15}", "<CFKeyedArchiverUID 0x2822214c0 [0x1dc4981b8]>{value = 16}", "<CFKeyedArchiverUID 0x2822214e0 [0x1dc4981b8]>{value = 17}", "<CFKeyedArchiverUID 0x282221500 [0x1dc4981b8]>{value = 18}" ); }, NSURLSessionResumeCurrentRequest, NSURLSessionResumeOriginalRequest, NSURLSessionDownloadURL, NSURLSessionResumeInfoTempFileName, NSURLSessionResumeBytesReceived, NSURLSessionResumeEntityTag, NSURLSessionResumeInfoVersion, NSURLSessionResumeServerDownloadDate, { "$class" = "<CFKeyedArchiverUID 0x282221540 [0x1dc4981b8]>{value = 11}"; "NS.data" = {length = 2427, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 0000083b }; }, { "$classes" = ( NSMutableData, NSData, NSObject ); "$classname" = NSMutableData; }, { "$class" = "<CFKeyedArchiverUID 0x282221540 [0x1dc4981b8]>{value = 11}"; "NS.data" = {length = 1666, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 00000594 }; }, https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_1280_10MG.mp4, CFNetworkDownload_BVLTmU.tmp, 871422, "5f074cdf-962771", 5, Thu, 09 Jul 2020 16:59:11 GMT, { "$classes" = ( NSMutableDictionary, NSDictionary, NSObject ); "$classname" = NSMutableDictionary; } ) , AnyHashable("$top"): { NSKeyedArchiveRootObjectKey = "<CFKeyedArchiverUID 0x2822212c0 [0x1dc4981b8]>{value = 1}"; }, AnyHashable("$version"): 100000]
the value i want in this string is "CFNetworkDownload_BVLTmU.tmp" which i dont know how to get it in code i dont see any key value for it can somebody help me ?
If I get it right you're trying to lookup a specific element by its value into a
Dictionary<AnyHasable, Any>… Then you have to rely onfirst(where:)and in the closure do type casting of the element's value to the type of the value (which has to conform toEquatable) you're looking for and then check for equality against it.Something as in: