Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

unimplemented initializer

Hello, just learning Swift and can't seem to get past an error message.


Built a tiny class and then wanted to create an XCTestCase and get the following:


fatal error: use of unimplemented initializer 'init(selector:)'


I can't seem to figure out why this is happening. I've narrowed it down to when I actually use a class file I created (a separate file in the project) the error occurs, but when I just do the skeleton test case, it works.


Course.swift

import Foundation


class Course {

var address: String = ""

var phone: String = ""

var tees = [String: Scorecard]()

init (address: String, phone: String) {

self.address = address

self.phone = phone

}

func add(scorecard: Scorecard) {

self.tees[scorecard.description] = scorecard

}

func delete(description: String) -> Bool {

if let _ = self.tees.removeValueForKey(description) {

return true

} else {

return false

}

}

}


import XCTest

@testable import Golf_League_Manager


class Golf_League_ManagerTests: XCTestCase { //BLOWS UP HERE WITH ERROR ABOVE✖

var course: Course

override func setUp() {

super.setUp()

// Put setup code here. This method is called before the invocation of each test method in the class.

//self.course = Course(address: "51 Baldwin Road, Billerica, Massachusetts 01821", phone: "614-332-8006")

}

override func tearDown() {

// Put teardown code here. This method is called after the invocation of each test method in the class.

super.tearDown()

}

overrideinit() {

self.course = Course(address: "", phone: "")

super.init()

}

func testAddress() {

//XCTAssertNotEqual("", course.address)

}

func testPhone() {

//XCTAssertNotEqual("", course.phone)

}

}

Posted on Nov 25, 2015 12:02 PM

Reply

There are no replies.

unimplemented initializer

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.