Questions tagged [optional-values]
79 questions
2
votes
2 answers
Unexpectedly found nil while unwrapping an Optional value when passing data backward
I have learned Swift and Xcode for about 3 weeks and I am doing an Todo App just for practice. But when I was trying to add new item to my todo list the error occurred saying that "Unexpectedly found nil while unwrapping an Optional value".
I have…

Bad Son
- 131
- 2
- 16
2
votes
0 answers
Redux/typescript selectors for optional values best practices?
So I have a key in my redux state roomId that is only undefined for a short amount of time. After that it will always be defined.
Now the problem is that my state looks like this:
interface State {
roomId?: string;
}
And my selector
export const…

Totty.js
- 15,563
- 31
- 103
- 175
2
votes
2 answers
Swift flatMap: How to remove only tuples from an array where specific element in the tuple is nil?
I have an array of tuples where the tuple contains some optional values:
let arrayOfTuples: [(Int, String?, String?)] = ...
How can I best remove from the array those tuples where the second element of the tuple is nil (no matter if the 3rd element…

Super Geroy
- 123
- 1
- 10
2
votes
2 answers
MailComposeViewController Error: unexpectedly found nil
I'm trying to save the email and time of an email i sent, to a table view. The emails send fine, but I get this error (Error: unexpectedly found nil while unwrapping an Optional value) whenever I click the send button. I'm not sure where is the…

Nyxx
- 303
- 3
- 13
2
votes
2 answers
Confused about optional value in swift
I'm new to swift and I don't really understand how to use optional value correctly.
The situation is: Firstly, I have a model class to store some values of its properties and send the request to server to get values. code:
import Foundation
class…

Hongxu Jin
- 817
- 2
- 9
- 16
2
votes
1 answer
simple image data passing from collection view to view controller fail
This is seriously starting to drive me crazy, since it s really simple.
I have a collectionviewcell that gets images from phone library
When i tap a cell, i get the index of the fetched collection (i m using Photo Framework), then send the selected…

Yann Massard
- 283
- 2
- 16
2
votes
2 answers
How do I evaluate "&optional argument" in emacs lisp?
I dont understand how to evaluate "&optional argument" in emacs lisp.
My code is:
(defun test-values (a &optional b)
"Function with an optional argument (default value: 56) that issues a
message indicating whether the argument, expected to be…

Efrain Romano
- 31
- 1
- 3
2
votes
3 answers
fatal error: unexpectedly found nil while unwrapping an Optional value(When adding to a array)
I have some code that receives value from a segue and replaces a certain element of an array with the index number that I have.
The initialization of the variables is:
var noteTitles: [String] = ["Sample Note"]
var noteBodies: [String] = ["This is…

SentientBacon
- 1,509
- 3
- 11
- 19
2
votes
1 answer
fetchedResultsController core data fatal error: unexpectedly found nil while unwrapping an Optional value
I know there are innumerable questions with the same error but none of the solutions seemed to work.
I want to make a blog reader app that saves and fetches data from the CoreData. I am able to save the JSON results into the CoreData, but when i try…

Swapna Lekshmanan
- 514
- 10
- 30
1
vote
2 answers
How to select random values from the list?
from random import Random
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from…

Carl Carl
- 27
- 6
1
vote
1 answer
Do select and checkboxes values, in HTML forms, support non latin characters?
I have the following code in a web form:

limakid
- 71
- 11
1
vote
0 answers
regex with optional character/class/group doesn't seem to work
Regex operator ? for optional character/class/group seems to fail.
Karate version: 0.9.9.RC1
I tried to match a phone number with optional leading + sign against these, but fails to match
#regex \+?\d{6,11}
#regex…

user2943111
- 421
- 1
- 5
- 15
1
vote
0 answers
Sequelize nested were when the subject of the include is possibly null
In my models I have a User which belongsTo({ model: Company, as: 'company' }) (and conversely Company hasMany({ model: User, as: 'members' }))
I have constructed a query as follows
const query = {
where: { onboardingState: 'pending' },
include:…

Dave Sag
- 13,266
- 14
- 86
- 134
1
vote
2 answers
Optional character match regex
I have a condition where my string could look like:
test23@testbee:/var/bee/
or
testbee:/var/bee/test.html
I need to extract three string here: test23 (if it is available) , testbee and test.html
So, in Perl,
($user, $sys, $file) = ($source =~…

new_linux_user
- 721
- 1
- 7
- 11
1
vote
0 answers
Realm Object fields are nil while unwrapping an Optional value
I'm having a strange issue with objects in Realm. When i fetch an object from Realm database at first time & deleted object from database. unwrapping an optional value nil.
Model:
class Outlet: Object {
@objc dynamic var id:string = ""
…

venkat
- 21
- 9