Can't unwrap Optional.None tableviewcell
Posted
by
Mathew Padley
on Stack Overflow
See other posts from Stack Overflow
or by Mathew Padley
Published on 2014-06-10T11:10:55Z
Indexed on
2014/06/11
9:25 UTC
Read the original article
Hit count: 227
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
© Stack Overflow or respective owner