Questions tagged [unwrap]
181 questions
1
vote
2 answers
How to change value of a Object Struct in SWIFT 5
I am trying to get value from JSON type, bring it to my var cryptos. But nothing change, var cryptos still nil. Even value of cryptos in Update void has changed. I have struggled with this problem for many hours. Thanks for your answer.
This is my…

Tuan Ho Si
- 25
- 5
1
vote
2 answers
SwiftUI, Fatal error: Unexpectedly found nil while unwrapping an Optional value
func loadImageFromUrl() {
guard let urlString = self.urlString else {
return
}
let url = URL(string: urlString)!
let task = URLSession.shared.dataTask(with: url, completionHandler:…

Charlotte L.
- 143
- 3
- 13
1
vote
2 answers
Using the OpenCV Phase Unwrapping Function in Python
I would like to use the OpenCV phase unwrapping functions presented here in Python, but I've been unable to find the function inside the cv2 namespace (this module). Has anyone else used this function outside of C++? I know there is an unwrap…

Sam Jett
- 710
- 1
- 6
- 15
1
vote
1 answer
Is there any way of doing unwrap_or_return an Error (any error)
Is there any way to simplify the returns in the following example (originally copied from here):
use std::num::ParseIntError;
fn multiply(first_number_str: &str, second_number_str: &str) -> Result {
let first_number = match…

Omid
- 460
- 3
- 13
1
vote
1 answer
Unwrap unnecessary nested divs in HTML string (NodeJs)
Is there a good npm package that can remove unnecessary nested tags in an html string running on a nodeJS server (no browswer DOM)? I've tried sanitize-html, but it doesn't seem possible to do this.
I receive email html from the user, so I can't…

user3055383
- 11
- 1
1
vote
1 answer
Swift: Can't unwrap an optional inside a loop
I can't understand why unwrapping an optional value is possible in this case:
let name: String? = "Toto"
guard let name = name else { fatalError() }
print(name)
but not when this snippet is wrapped in a for-loop:
for _ in 0..<100 {
let name:…

Louis Lac
- 5,298
- 1
- 21
- 36
1
vote
2 answers
Are there any nice cases where we should use `unwrap`?
Since using unwrap may be problematic because it crashes in the error scenario, it may be considered as dangerous usage.
What if I am hundred percent sure that it will not crash, like in the following scenarios:
if option.is_some() {
let value =…

Akiner Alkan
- 6,145
- 3
- 32
- 68
1
vote
2 answers
leaving textfields blank - crash - swift 4
I am trying to create a course avg calculator with textfields. However if I only want to enter in a few marks (i.e. not filling out all the textfields) I get a crash.
I get this error:
Thread 1: Fatal error: Unexpectedly found nil while unwrapping…

MontgommeryJR
- 255
- 3
- 18
1
vote
3 answers
How to unwrap an optional dictionary value in Swift 4+ in one step?
Given the dictionary of dictionary below, what is the correct syntax to unwrap the Int? in one step?
let dict:Dictionary> = [
"parentKey" : [
"firstKey" : 1,
"secondKey" : nil]
]
let x = "someKey"
let y =…

Andrew Coad
- 297
- 2
- 13
1
vote
2 answers
Haskell unwrap Maybe keep polymorphism
Haskell beginner here again. If I want to unwrap a Maybe type and want to keep it abstract I would use:
fUnwrap :: Maybe a -> a
fUnwrap (Just n) = n
fUnwrap Nothing = ???
No matter what I do with Nothing, compiler keeps nagging about being more…

Madderote
- 1,107
- 10
- 19
1
vote
1 answer
How to wrap unwrap private key?
My code for wrap and unwrap public and private key
public void BasicWrapAndUnwrapKeyTest()
{
using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.AppType))
{
// Find first slot with token present
Slot…

Noppadol
- 11
- 3
1
vote
1 answer
Converting Blender's UV vectors into 3D coordinates
I have converted a UV vector coordinates into 3D plane using Blender's Bmesh function. Using bmesh to create the newer mesh,
bm.faces.new((vert))
it creates faces that is undesirable, or more accurately, the edges and faces that are generated by…

Jiong Le
- 13
- 2
1
vote
1 answer
Swift: "Value of optional type '(Int, Int)?' not unwrapped; did you mean to use '!' or '?'?
class Game {
var board: [[Int]]!
var turns: Int!
let coordinates = [1:(0,0), 2:(0,1), 3:(0,2), 4:(1,0), 5:(1,1), 6:(1,2), 7:(2,0), 8:(2,1), 9:(2,2)]
init() {
self.reset()
}
func reset() {
self.board =…

Philip Lee
- 93
- 3
- 7
1
vote
2 answers
"Fatal error: unexpectedly found nil while unwrapping an Optional value" while querying from CloudKit
I'm trying to get the current users first name from CloudKit using the following code:
func getUserFirstName() -> String{
var firstNameFromFunction: String?
var currentuserID : CKRecordID?
…

user4174219
- 427
- 5
- 13
1
vote
0 answers
How to deserialize JSONP in C#?
I am using a payment module API to generate a token. I make a HttpWebRequest and I need to deserialize response as per my [DataContract]. The issue I am facing is the response contains a padding, "OnCallback".
`OnCallback(
{"status":201,…

Marij Siddiqui
- 35
- 2