谢谢您阅读此篇.我想有一个函数Swift文件,我把我的项目的所有函数放入其中,其他Swift文件可以调用.我试图在函数文件中创建一个警报函数,当我传入一个特定的字符串时,它会显示一个特定的警报.当它在主文件中时它正在工作,但当我将它移动到函数文件时,presentViewController给我一个错误,说"使用未解析的标识符'presentViewController'." 请帮忙!这是我的代码:在函数文件中:
import Foundation
import UIKit
/**********************************************
Variables
***********************************************/
var canTapButton: Bool = false
var tappedAmount = 0
/**********************************************
Functions
***********************************************/
//the alert to ask the user to assess their speed
func showAlert(alert: String) -> Void
{
if(alert == "pleaseAssessAlert")
{
let pleaseAssessAlert = UIAlertController(title: "Welcome!", message: "If this is your firs time, I encourage you to use the Speed Assessment Tool (located in the menu) to figure which of you fingers is fastest!", preferredStyle: .Alert)
//ok button
let okButtonOnAlertAction …Run Code Online (Sandbox Code Playgroud)