Reputation:
2 working code under but when i checked it to swift 2 gives me this error :
ViewController.swift:55:50: 'new()' is unavailable in Swift: use object initializers instead
My all codes here
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
if self.revealViewController() != nil {
menuButton.target = self.revealViewController()
menuButton.action = "revealToggle:"
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
self.adBannerView?.adUnitID = kAdmobIDBanner
self.adBannerView?.rootViewController = self
var request = GADRequest()
self.adBannerView?.loadRequest(request)
var connection : APIConnection = APIConnection();
MBProgressHUD.showHUDAddedTo(self.view, animated: true)
connection.startRequest(String(format:"%@getAllCuisines.php",kServerURl), responseBlock: { (data :[AnyObject]!) -> Void in
var jsonResult: NSArray = data as NSArray;
if((jsonResult.valueForKey("success").boolValue) == true)
{
self.dataArray = jsonResult.valueForKey("cuisine") as! NSArray
self.tableview?.reloadData();
MBProgressHUD.hideHUDForView(self.view, animated: true)
}
else
{
}
}) { (error : NSError!) -> Void in
MBProgressHUD.hideHUDForView(self.view, animated: true)
//code
}
self.tableview?.tableFooterView = UIView.new() // HERE GIVES ERROR
}
I try everything but i didnt resolve it. Please help me
Upvotes: 0
Views: 2000
Reputation: 71852
UIView
doesn't have any property called new()
in swift so you can directly assign UIView
to your tableFooterView
this way:
self.tableview.tableFooterView = UIView()
Or you can assign any custom view to it.
Upvotes: 0
Reputation: 2754
Calling new() is not the proper way to initialize objects in Swift. When creating an intance of a UIView usually you should write something like this:
self.tableview?.tableFooterView = UIView(frame: aRect)
In your case you might want to initialize the view with CGRectZero
Upvotes: 1