Swift变量和内存使用情况

时间:2016-01-12 04:28:33

标签: ios swift memory-management

我使用storyboard segue在整个应用程序中导航。我为segue identifiertable cell identifier声明了字符串变量。所以我不会在视图控制器类中输入任何拼写错误。

import UIKit

private let showTripViewSegueIdentifier = "showTripView"
private let contactCellIdentifier = "contactCell"

class JobViewController: UIViewController , UITableViewDataSource,UITableViewDelegate{
}

是否会影响应用程序的内存使用量? (因为整个应用程序会有很多视图控制器)。这是一个好方法吗?

提前致谢。

3 个答案:

答案 0 :(得分:1)

它不会产生重大影响。无论如何都必须将字符串存储在某处,因为您在运行时使用它们。

答案 1 :(得分:1)

声明这样的枚举:

enum SegueIdentifier:String {     案例SegueIdentifier1     案例SegueIdentifier2     案例SegueIdentifier3 }

答案 2 :(得分:1)

它不应该有所作为。但是,更好的方法是使用上面Arun提到的枚举。

例如 -

enum SegueIdentifier{
    case showTripView
    case contactCell
}

并借助较短的点语法在代码中使用它。例如 - .contactCell