Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

ios - Property 'self.*' not initialized at super.init call

I just updated my xcode to 6.3.1. The problem is I got this weird error message since Swift 1.2. I got this kind of error message

/Users/MNurdin/Documents/iOS/xxxxx/Library/SideBar.swift:32:15: Property 'self.originView' not initialized at super.init call

/Users/MNurdin/Documents/iOS/xxxxx/Library/SideBar.swift:38:20: Immutable value 'self.originView' may only be initialized once

on this code

let originView:UIView?

override init() {
        super.init() //error here

    }

    init(sourceView:UIView, menuItems:Array<String>){
        super.init() //error here
        originView = sourceView //error here
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have to initialize all property before you call super.init in any init method

So,change this before you call super.init()

originView = sourceView //error here

Exception:

  1. optional property
  2. property with default value
  3. lazy property

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...