Questions tagged [unwrap]

181 questions
3
votes
1 answer

Cannot force unwrap value of non-optional type 'Reachability' for swift 5

I get the warning xcode 11.1 for iOS 13 (swift 5) Cannot force unwrap value of non-optional type 'Reachability' on the line let reachability = Reachability()! I tried, if statements and try do, but none seem to work.Removing the ! gives the warning…
Wil
  • 351
  • 3
  • 9
3
votes
3 answers

Swift: I got " Unexpectedly found nil " in "tableView.delegate=self"

I connect a segue between a button and a view controller as shown in the screenshoot. Everything works until I choose the class as "ViewController". Every time I click the "Add" button, the code crashes with following error:"Thread 1: Fatal error:…
3
votes
0 answers

Unwrap to remove discontinuity

I am stuck in this problem for a long time. I would really appreciate any help I can get. I have a complex equation which has branch cuts (4 of them, but in the attached code I just have one). This shows phase jumps across the y-axis. I am trying to…
3
votes
3 answers

Unwrapping optionals to a pre-defined variable in the guard condition without creating a new constant

The Swift guard statement allows you to unwrap optionals to a new constant and do an early return if the assignment fails. var someString:String? = "hello" ... ... guard let newString = someString else { return } ... If I want to…
GingerBreadMane
  • 2,630
  • 1
  • 30
  • 29
3
votes
3 answers

Why unwrap a variable that can not be nil?

New to Swift and saw code from Standford open course of Swift programming as below: if pending != nil { acccumulator = pending!.binaryFunction(pending!.firstOperand,acccumulator) pending = nil } As I learn about unwrapping, pending, in this…
Alan Hoo
  • 445
  • 3
  • 12
3
votes
2 answers

Converting [Int?] to [Int]

I have a String, e.g. "7,8,9,10" that I'd like to convert to an array of Int items i.e. [Int] However, my code currently gives me a [Int?] instead (an array of optional integers). Here is the code: let years = (item["years"] as! String) …
Ben
  • 4,707
  • 5
  • 34
  • 55
3
votes
4 answers

Unwrapping either one of two types in Swift

I have a method which does exactly the same thing for two types of data in Swift. To keep things simple (and without duplicating a method) I pass AnyObject as an argument to my method which can be either of these two types. How to I unwrap it with…
kernelpanic
  • 2,876
  • 3
  • 34
  • 58
3
votes
4 answers

How to remove span inside an element?

The following code adds and removes an "active" class to a menu (.active) It also adds a span class to the active link . How can I remove this span class? I've tried unwrap but it doesn't remove the span class…
Sébastien Gicquel
  • 4,227
  • 7
  • 54
  • 84
3
votes
1 answer

how to disable line wraparound in Microsoft Word 2010 outline view

In outline view, the lines begin wrapping around if they're more than about 50 characters or so. How can this wraparound be disabled?
Doug Null
  • 7,989
  • 15
  • 69
  • 148
2
votes
1 answer

JavaScript WebCryptoApi: Why does this not satisfy operation specific requirements?

Setup: I generate a key-encryption-key (kek, AES-GCM, 256) I generate a RSA-OAEP keypair I wrap the generated private key with the kek using AES-GCM-256 and a random iv, exported as pkcs8 I try to unwrap the key, this fails at the "import"…
shilomig
  • 57
  • 4
2
votes
1 answer

Rust: Make unwrap() print error.display() instead of error.debug()

In a Rust program, I am using a Result which uses a String as its Error type: fn foo() -> Result The String I return as an error looks something like this: lorem\nipsum Now I call my function and unwrap it as such: foo.unwrap(); Now…
Dalit Sairio
  • 125
  • 3
2
votes
1 answer

Issue with unwrapping optionals in my model and DTO

This might be something really easy but I don't understand how to do it: so I have this DTO struct I use to get API data into it and map it to Model struct my DTO: struct PetDTO: Codable { var id: Int var category: CategoryDTO? var name:…
Shum
  • 23
  • 5
2
votes
3 answers

How to separate JSON object on pieces?

I am using Jackson and I have the following JSON structure. { "person": { "person1": {"name": "daniel", "age": "17"}, "person2": {"name": "lucy", "age": "19"} } } And I want to get the following result or separate them. Json1: { …
Daniel
  • 181
  • 4
  • 13
2
votes
1 answer

How to unwrap bulk plsql packages?

I have the below code in a bat file to wrap all the packages present in a folder where the bat file was executed. @echo off for /R %%f in (*.pkb) do ( wrap iname="%%~dpnxf" oname="%%~dpnf.plb" DEL %%~dpnxf ) Can…
vineeth
  • 641
  • 4
  • 11
  • 25
2
votes
1 answer

Unwrapping atan vs. atan2

I can extract the phase of a complex number in Matlab using the atan() or atan2() functions. atan() returns in interval limited to [-pi/2,pi/2], and atan2() returns in interval limited to [-pi,pi]. I want to see if I can unwrap the extracted phase…
Liz Salander
  • 321
  • 3
  • 14
1
2
3
12 13