了解TableView中的localizedTitle和localizedDescription

时间:2016-08-10 00:56:50

标签: ios swift uitableview in-app-purchase skproduct

我目前正在实施应用内购买机制,有三件事我不完全理解。

在下表中查看我是否使用单例类从app风暴中检索产品,有三件事我不确定他们究竟做了什么...

as! SKProduct做了什么?

localizedTitlelocalizedDescription做了什么?

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = UITableViewCell(style: .Subtitle, reuseIdentifier: "reuseIdentifier")
    // what does `as! SKProduct` do
    let product = IAPManager.sharedInstance.products.objectAtIndex(indexPath.row) as! SKProduct

    // what does localizedTitle do?
    cell.textLabel!.text = product.localizedTitle
    // what does localizedDescription do?
    cell.detailTextLabel!.text = product.localizedDescription

    return cell
}