简体   繁体   中英

xcode 6 swift Slow typing & Autocompletion

i suffer with typing & Autocompletion it takes too much time, this issue occurs only when the swift file has more than 1500+ Line code. with small lines codes for example under 1000 Line everything will be Fine.

so I've tried to split the swift View controller file into 2 swift files,

I've taken the longer functions from the view Controller and paste them into the new swift file, xcode 6 works just as expected.

But a new problem arises which swift doesn't support importing swift file Into another Swift File. so i've created an instance of the view controller in the newly created swift file, so i thought i saved the problem, but the instance of the view controller can only access Variables, Constants,And Functions,

check the error

viewController.swift

viewController: UIViewController
{
  var someClass = foo() // assuming this class has x = 5
  var x: Int = 10
}

testFile.swift

 import Foundation
 let beginTest = viewController()
  func testPrint()
  {
    println("x in view Controller = \(beginTest.x)") // prints 10 
    println("x in the foo() = \(beginTest.someClass.x)") // Error view controller doesn't have a member named someClass

  }

How can i solve this problem, without creating instances or importing files.

or

How can i solve this problem, with Creating instances of view Controller ?

Ps I have Macbook Air mid 2013, core i5, 4Gb, Intel HD Graphics 5000 1536MB

You should be using 'extension' s in swift to logically split your implementation of a class as required. Refer documentaion

For example, we can split implementation of a class A thusly in two files:

//A.Swift 

class A
{
    func func1() -> String {
        return "func1"
    }
//Other functions...


}

//A_Extension.swift

extension  A
{
    func funcB() -> String
    {
        return "B"
    }
 //Other functions if any...


}

If you have test coverage data gathering enabled (edit scheme, test) disable it. For me this speeds up editing by order of magnitude.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM