2014-07-21 79 views
3

我正在測試swift語言。 突然xcode終止,沒有顯示錯誤。 但得到了以下信息:xcode與蘋果swift問題

來源配套服務終止編輯功能暫時限制

import UIKit 

class ViewController: UIViewController { 

    override func viewDidLoad() { 
     super.viewDidLoad() 
     // Do any additional setup after loading the view, typically from a nib. 
     self.myfunction() 

     //ViewController.classFunc() 

     //myfunctionWithArg() 
     //myfunctionWithArg(name: "hashim") 

     //learnSwitch() 

     self.learnClosure() 

     /* 
     let anInstance = MyClass() 
     anInstance.aFunction() 

     let someVehicle = Vehicle() 
     println(someVehicle.description) 

     someVehicle.description = "test" 

     let aCycle = Cycle() 
     println(aCycle.description) 
*/ 
    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 




     func learnClosure(){ 

     let retValue = jediGreet("old friend") 
     println(retValue) 
     println(retValue.0) 
     println(retValue.1) 

     let train = jediTrainer("hashim") 
     println(train("new programming swift", 3)) 

     println((jediTrainer("hashim"))("Obi Wan", 3)) 

     var names = ["fashim","hashim","ashim","bashim","cashim","dashim"] 

     sort(names, { (s1:String,s2:String)-> Bool in 
      println("test arg1:\(s1), arg2:\(s2)") 
      return s1>s2 } ) 

     sort(names, >) 
      println(sort(names, <)) 




     /* 
     let myadd = { (sum:Int,number:Int)->Int in 

      return (sum + number) 

     } 
     */ 

    // let myadd = { ($0 + $1) } 


    // println("sum is \(myadd(3,4))") 

     let padawans = ["Knox", "Avitla", "Mennaus"] 

     println(padawans.map({ 
      (padawan: String) -> String in 
      "\(padawan) has been trained!" 
      })) 


     var numbers = [10,1,20,123,50] 

     println("before \(numbers)") 
     mySort(numbers,{ 
      (num1:Int,num2:Int) -> Bool in 

      return num1 > num2 

      }) 
    println("after \(numbers)") 

    } 

    func mySort(numbers:Int[],compare:((Int,Int)->Bool)) 
    { 
     //Write your login to sort numbers using comparator method 
     var tmp:Int 
     var n = numbers.count 

     for(var i=0;i<n;i++) 
     { 
      for(var j=0;j<n-i-1;j++) 
      { 
       if(numbers[j] > numbers[j+1]) 
       { 
        tmp=numbers[j]; 
        numbers[j]=numbers[j+1]; 
        numbers[j+1]=tmp; 
       } 
      } 
     } 
    } 



    func repeat (count:Int,task:()->()){ 

     for i in 0..count{ 

      task() 
     } 

    } 


    func jediGreet(String) -> (farewell: String, mayTheForceBeWithYou: String) { 
     return ("name" , " May the (ability) be with you.") 
    } 

    func jediTrainer (caller:String) -> ((String, Int) -> String) { 
     func train(name: String, times: Int) -> (String) { 
      return "\(name) has been trained in the Force \(times) times calling \(caller)" 
     } 
     return train 
    } 


} 

回答

4

這種情況可能是由於在Xcode幾個原因(這只是因爲迅速仍處於測試階段) 。在你的情況下,只需評論行// println(train(「new programming swift」,3))。如果你想得到這個功能,將該行代碼分成兩個