0
votes

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 ?

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

2
Why do you have 1500-line source code files? You shouldn't have this... this is your problem, not autocomplete failing... - nhgrif
Well, other user complains because the xcode suffer when it gets to 8000+ line source code, so 1500 are nothing compared to a video game source code :) - Mohamed Horani
There's nothing wrong with 1500 or 8000 lines of source code. The problem is when all of this source code are in the same file for absolutely no reason. You might be able to find a game with 8000 lines of source code in a single file, but you won't find any code authored by anyone that knows what they're doing that is anywhere near this many lines of source code. - nhgrif

2 Answers

0
votes

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...


}
0
votes

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