moving to SWIFT (slowly…)

I’m learning swift. And these series of posts is about the troubles i am facing. Mostly because i did not spend enough time to completely understand the documentation, but also because swift changes fast and LOTS of examples and posts on the internet are already out of date.

For example i found heaps of broken “cellForRowAtIndexPath” implementations.

This one does work(as of today….):

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cellIdentifier = "TableCell1"
        var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
        
        if (cell==nil) {
            cell = UITableViewCell.init(style: .Subtitle, reuseIdentifier: cellIdentifier)
            
        }
        cell?.textLabel?.text = "CellTextlabelText\(indexPath.row)"
        return cell!
    }

Another one that was more difficult than anticipated was “prepareForSegue”

    override func prepareForSegue(segue: UIStoryboardSegue?, sender: AnyObject?) {

            let next:ListeTableView = segue!.destinationViewController as! ListeTableView
        
            next.daten = self.daten
        
    }

both viewcontrollers have an array of Objects as a member:

import UIKit

class ListeTableView: UITableViewController {
    
    var daten: [Shops] = []
    
// more....


}

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.