如何在Swift

时间:2015-10-12 22:23:30

标签: string swift if-statement

我在视图控制器的代码中创建了一些变量(基本上,我只是检查分段控件的值),但是当我尝试写入循环中的字符串时(如下所示)没有写任何内容,所有字符串都保留了#n; nil。"

var textTypeVideo:String?
var textMultipleAgents:String?
var textAdditionalRooms:String?
var textMultipleVideos:String?
var textTurnaround:String?

以下是检查分段控件所在位置的函数:

@IBAction func typeOfVideoAction(sender: AnyObject) {
    if typeOfVideoControl.selectedSegmentIndex == 0 {
        textTypeVideo = "Standard Home Video"
    } else {
        textTypeVideo = "Standard CV Video"
    }
}

@IBAction func mulitpleAgentScenesAction(sender: AnyObject) {
    if multipleAgentScenesControl.selectedSegmentIndex == 0 {
        textMultipleAgents = "Multiple Agent Scenes Desired"
    } else {
        textMultipleAgents = "No Multiple Agent Scenes"
    }
}

@IBAction func additionalRoomsAction(sender: AnyObject) {
    if additionalRoomsFeaturesControl.selectedSegmentIndex == 0 {
        textAdditionalRooms = "Additional Rooms & Features Desired"
    } else {
        textAdditionalRooms = "No Additional Rooms & Features"
    }
}

@IBAction func multipleVideosAction(sender: AnyObject) {
    if multipleVideoCopiesControl.selectedSegmentIndex == 0 {
        textMultipleVideos = "Second Video Copy Requested"
    } else {
        textMultipleVideos = "No Second Video Copy"
    }
}

@IBAction func turnaroundAction(sender: AnyObject) {
    if turnaroundControl.selectedSegmentIndex == 0 {
        textTurnaround = "No Quick Turnaround"
    } else if turnaroundControl.selectedSegmentIndex == 1 {
        textTurnaround = "24 Hour Turnaround Desired"
    } else if turnaroundControl.selectedSegmentIndex == 2 {
        textTurnaround = "2 Business Day Turnaround Desired"
    } else if turnaroundControl.selectedSegmentIndex == 3 {
        textTurnaround = "3 Business Day Turnaround Desired"
    } else {
        textTurnaround = "5 Business Day Turnaround Desired"
    }
}

最后,这是我想要填写并打印在电子邮件中的内容:

   let messageBody = "\(textTypeVideo) and \(textMultipleAgents) and \(textAdditionalRooms) and \(textMultipleVideos) and \(textTurnaround)"
    mailComposerVC.setMessageBody(messageBody, isHTML: false)

非常感谢任何帮助!基于分段控件,我似乎无法根据它们应该是什么来填充顶部变量!感谢。

0 个答案:

没有答案