anyobject Questions
5
Solved
How could we convert anyobject to string in swift 3, it's very easy in the older version by using.
var str = toString(AnyObject)
I tried String(AnyObject) but the output is always optional, even...
3
I have a generic struct declared as follows:
struct WeakReference<T: AnyObject> {
weak var value: T?
init(value: T?) {
self.value = value
}
}
And a protocol:
protocol SomeProtocol: c...
3
Solved
Hello StackOverflow :)
I've been running into a weird problem since I upgraded to swift 2.0
I'm trying to set a border color, so I'm writing self.layer.borderColor = borderColor as! CGColor where...
Mirisola asked 7/11, 2015 at 23:52
1
1
Solved
let json = [
"left" : 18,
"deadline" : "May 10",
"progress" : 0.6
] as [String: AnyObject]
let ss = json["progress"] as? Float
let sss = json["progress"] as? Double
print("ss = \(ss)\n sss = \(...
2
Solved
I created an extension on 'Dictionary' to help me parse JSON. The method below helps me do this:
func toJSONString() -> String? {
if let dict = self as? AnyObject {
if let data = try? JSONSer...
Hengel asked 30/9, 2016 at 20:18
3
Solved
I want to get Addresses from profile dictionary,but I got the error "type any? has no subscript members"
var address:[[String : Any]] = [["Address": "someLocation", "City": "ABC","Zip" : 123],["Ad...
Disincentive asked 15/8, 2016 at 14:13
2
Solved
there are two situation make me confuse when develop swift 2.2 by using Xcode 7.1, please see the example below, thanks
First, when import Foundation, I declared an testArray which contains two i...
Dharma asked 4/5, 2016 at 9:46
4
Solved
This question was inspired by mz2's answer on the question Check for object type fails with "is not a type" error.
Consider an empty Swift class:
class MyClass { }
Attempting to call ...
Arella asked 25/4, 2016 at 22:0
2
In Swift, how is it that AnyObject supports subscripts, even for types that are't subscriptable? Example:
let numbers: AnyObject = [11, 22, 33]
numbers[0] // returns 11
let prices: AnyObject = ["...
2
Solved
In Java you can some times use generics without caring about the actual type.
Can you do that in Swift?
For instance MyClass<AnyObject> doesn't work like MyClass<?> would in Java. At I...
4
Solved
1
Solved
I'm trying to mark a variable of a generic type as weak:
class X<T> {
weak var t: T?
}
If I don't put in any constraints for T I get the error weak cannot be applied to non-class type 'T'...
1
© 2022 - 2024 — McMap. All rights reserved.