Swift 3: Unable to use instance in property initializer. The initializer starts before "self" is available.

I'm currently working on learning Swift 3, and I'm trying to implement an XML parser that parses data from a URL. I created a separate file for XML parsing and configured it as follows.

let xmlDoc = NSURL(string: "http://labs.bible.org/api/?passage=random&type=xml") var parser1 = XMLParser(contentsOf: xmlDoc) 

I am currently having problems with the syntax. Swift selects the line in which I initialize the XML parser and give the error "I can not use the member instance" xmlDoc "in the property initializer, the property initializers start up to" self ".

This is probably something very simple, but I could not find a solution in my search engines.

Any feedback is appreciated!

for -Alex-

+7
ios swift
source share

No one has answered this question yet.

See similar questions:

73
How to initialize properties that depend on each other
one
Instance member cannot be used for custom class type

or similar:

12
"self" is used before all stored properties are initialized
2
"Cannot use member instance" allEvents in property initializers; Property initializers run before "I"
one
cannot use the instance "country" in the property initializer; Property initializers start before "self" is available
one
Unable to use member instance 'movies1' in property initializer, property initializers start before 'self' is available
0
Getting an error. It is not possible to use the member instance 'url' in the property initializer; Property initializers start before "self" is available
0
Unable to use instance member in property initializer; Property initializers start before "self" is available
0
It is not possible to use an instance of the today instance in the property initializer; property initializers start before 'self' becomes available
0
Cannot use instance element of LinkString in property initializer; property initializers start before 'self' becomes available
-one
Cannot use instance instance 'getA' in property initializer; property initializers start before it becomes available
-3
Cannot use instance element 'month' in property initializer; property initializers start before 'self' becomes available

All Articles