Can't unwrap Optional.None tableviewcell
- by Mathew Padley
I've a table view that has a custom table view cell in it. My problem is that when i try and assign a value to a variable in the custom table view cell I get the stated error. Now, I think its because the said variable is not initialised, but its got me completely stumped.
This is the custom table cell:
import Foundation
import UIKit
class LocationGeographyTableViewCell: UITableViewCell
{
//@IBOutlet var Map : MKMapView;
@IBOutlet var AddressLine1 : UILabel;
@IBOutlet var AddressLine2 : UILabel;
@IBOutlet var County : UILabel;
@IBOutlet var Postcode : UILabel;
@IBOutlet var Telephone : UILabel;
var location = VisitedLocation();
func Build(location:VisitedLocation) -> Void
{
self.location = location;
AddressLine1.text = "test";
}
}
My cell for row at index path is:
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
var addressCell = tableView.dequeueReusableCellWithIdentifier("ContactDetail") as? LocationGeographyTableViewCell;
if !addressCell
{
addressCell = LocationGeographyTableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "ContactDetail");
}
addressCell!.Build(Location);
return addressCell;
}
As I say I'm completely baffled, the Build function calls the correct function in the tableviewcell.
Any help will be gratefully appreciated.
Ta