optional-variables Questions

2

Solved

So here I have a basic setup var preferenceSpecification = [String : String?]() preferenceSpecification["Key"] = "Some Key" preferenceSpecification["Some Key"] = nil preferenceSpecification["Defau...
Banderilla asked 18/8, 2016 at 19:39

3

Solved

I would like to traverse the view controller hierarchy in Swift and find a particular class. Here is the code: extension UIViewController{ func traverseAndFindClass<T : UIViewController>(...
Afterburning asked 13/9, 2014 at 22:1

3

Solved

Sometimes I find myself writing swift 2 code like this: class Test { var optionalInt: Int? var nonOptionalInt: Int = 0 func test() { if let i = optionalInt { nonOptionalInt = i } // do more...
Neurath asked 15/8, 2015 at 21:8

9

Solved

Given the following in Swift: var optionalString: String? let dict = NSDictionary() What is the practical difference between the following two statements: optionalString = dict.objectForKey("So...
Hierarchize asked 7/9, 2014 at 9:7

2

Solved

It's my understanding that var perhapsInt : Int? This is automatically set to a .None value. And the below code snippet confirms that (no compiler errors) class MyClass { var num1: Int = 0 v...
Connor asked 15/11, 2015 at 11:10

3

Solved

I have a case where I want to check if an optional I have is Equal to a string. First I have to unwrap it to check if it exists, then I want to check if it is equal to another string. However that ...
Nagaland asked 20/12, 2014 at 0:21

1

I am trying to fill the empty spaces generated by the use of Optional in the SPARQL query language. Are there any ways that I can achieve this? The use of !bound on the optional variable generate...
Termite asked 1/11, 2013 at 9:5

2

Solved

Assume that i have a function like this below It takes 3 parameters and 2 have optional values private void myfunc (int a, int b=2, int c=3) { //do some stuff here related to a,b,c } now i want...

4

Solved

I have many concrete-structs and I want to designate fields as optional (present or not-present). Just wondering what ideas people have for achieving this. Here is an example struct (fields can be ...
Smog asked 21/3, 2011 at 14:32

2

Solved

I have an optional POD struct that will be contained inside a union. boost::optional<> holds its type by value, so I thought this could work: union helper { int foo; struct { char basic...
Tayyebeb asked 12/1, 2011 at 20:53

3

Solved

What does the following mean? Class.Function(variable := 1 + 1) What is this operator called, and what does it do?
Uchish asked 15/10, 2008 at 14:17
1

© 2022 - 2024 — McMap. All rights reserved.