2015-01-02 3 views
0

나는 Swift에 앱을 가지고있다. 내가보기 컨트롤러가 :신속한 응용 프로그램 오류없이 충돌?

// 
// ViewController.swift 
// SwiftUIPickerFormatted 
// 
// Created by Codepixl 
// Copyright (c) 2014 
// 

import UIKit 

class FirstViewController: UIViewController,UIPickerViewDataSource,UIPickerViewDelegate,UIAlertViewDelegate { 

    @IBOutlet weak var chapterPicker: UIPickerView! 
    let chapterData = [1,2,3,4,5,6,7,8,9,10,11,12,13] 
    let lessonData = [1,2,3,4,5,6,7,8,9,10] 
    let classData = ["Pre Algebra","Algebra 1"] 
    var data = ["ade","01","01"] 
    override func viewDidLoad() { 
     super.viewDidLoad() 
     if(UIApplication.sharedApplication().canOpenURL(NSURL(string:"puffin://")!) == true){ 
      println("Can open Puffin links") 
     }else{ 
      showPuffinAlert() 
     } 
     chapterPicker.delegate = self 
     chapterPicker.dataSource = self 

    } 

    //MARK: - Delegates and datasources 
    //MARK: Data Sources 

    func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { 
     return 3 
    } 
    func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 
     if(component == 0){ 
      return classData.count 
     }else if(component == 1){ 
      return chapterData.count 
     }else if(component == 2){ 
      return lessonData.count 
     } 
     return 1 
    } 

    //MARK: Delegates 
    func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! { 
     if(component == 0){ 
      return classData[row] 
     }else if(component == 1){ 
      return "Chapter " + String(chapterData[row]) 
     }else if(component == 2){ 
      return "Lesson " + String(lessonData[row]) 
     } 
     return "Error!" 
    } 

    func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { 
     if(component == 0){ 
      if(row == 0){ 
       data[0] = "ade" 
      }else if(row == 1){ 
       data[0] = "ate" 
      } 
     }else if(component == 1 || component == 2){ 
      if(row+1 < 10){ 
       data[component] = "0"+String(row+1) 
      }else{ 
       data[component] = String(row+1) 
      } 
     } 
     println("puffin://www.phschool.com/webcodes10/index.cfm?wcprefix=\(data[0])&wcsuffix=\(data[1])\(data[2])&area=view") 
    } 
    func showPuffinAlert(){ 
     var createAccountErrorAlert: UIAlertView = UIAlertView() 

     createAccountErrorAlert.delegate = self 

     createAccountErrorAlert.title = "Oops!" 
     createAccountErrorAlert.message = "It seems you do not have the Puffin web browser installed, which is required for this app to work. You can go ahead, but be aware the video and textbook links will not work." 
     createAccountErrorAlert.addButtonWithTitle("I understand- Proceed.") 
     createAccountErrorAlert.addButtonWithTitle("I'll download Puffin for free.") 

     createAccountErrorAlert.show() 
    } 

    func alertView(View: UIAlertView!, clickedButtonAtIndex buttonIndex: Int){ 

     switch buttonIndex{ 

     case 0: 
      NSLog("Proceed"); 
      break 
     case 1: 
      NSLog("DL"); 
      UIApplication.sharedApplication().openURL(NSURL(string: "https://itunes.apple.com/us/app/puffin-academy/id716707933?mt=8#")!) 
      break 
     default: 
      NSLog("Default"); 
      break 
      //Some code here.. 

     } 
    } 
    @IBAction func GoVideo(sender: AnyObject) { 
     UIApplication.sharedApplication().openURL(NSURL(string:"puffin://www.phschool.com/webcodes10/index.cfm?wcprefix=\(data[0])&wcsuffix=\(data[1])\(data[2])&area=view")!) 
    } 
} 

을 그리고는 "나는 진행을 이해하기"또는 "무료을 다운로드합니다 앵무"또는 GoVideo을 공격 버튼 -이 오류없이 충돌 할 때까지 모두 잘 작동합니다. 내가 무슨 일이 일어나고 있는지에 관해서 여기 완전히 곤란하다 ...

편집 : 나는 또한 내 빌드 폴더를 지우고 그것에서 모든 것을 삭제했다. 또한 내 애플 리케이션 델리게이트와 뷰 컨트롤러에 println을 추가했다. 업데이트, 그리고 그들은있다. 또한 시뮬레이터가 지워졌습니다.

+0

시뮬레이터를 재설정 해 보셨습니까? –

+0

@ShaanSingh 예. 또한 실제 iOS 기기를 사용해 테스트하고 있습니다. 시뮬레이터와 장치에도 동일한 문제가 있습니다. – user3042719

+0

UIAlertView는 iOS 8에서 사용되지 않습니다. UIAlertController로 코드 재 작성을 시도해 볼 수 있습니까? –

답변

0

아마도 Xcode 프로젝트에 손상된 파일이 있습니다. 그냥 새로운 프로젝트를 만들고 코드를 사용해보십시오.

+0

바로 가기는'rm -rf "$ (getconf DARWIN_USER_CACHE_DIR) /org.llvm.clang/ModuleCache"'일 수 있습니다. –