• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
'unowned' cannot be applied to non-class type
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

'unowned' cannot be applied to non-class type


  • Subject: 'unowned' cannot be applied to non-class type
  • From: Rick Mann <email@hidden>
  • Date: Fri, 12 Feb 2016 13:37:17 -0800

I'm having trouble getting this code to compile:

class ...
{
    var deleteButton : UIBarButtonItem =
    {
        [unowned self] in
        let button = UIBarButtonItem(barButtonSystemItem: .Trash, target: self, action: "deleteSelection:")
        return button
    }()
}

I get

'unowned' cannot be applied to non-class type 'ModelBrowserController -> () -> ModelBrowserController'

and

Cannot convert value of type 'ModelBrowserController -> () -> ModelBrowserController' to expected argument type 'AnyObject?'

when referencing self.

Google tells me the solution to the second error is to add [unowned self] to the declaration, but then I get the other error about 'non-class type'.

Help! Thanks!

--
Rick Mann
email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: 'unowned' cannot be applied to non-class type
      • From: Rick Mann <email@hidden>
  • Prev by Date: UITableView -reloadData woes
  • Next by Date: Re: UITableView -reloadData woes
  • Previous by thread: Re: UITableView -reloadData woes
  • Next by thread: Re: 'unowned' cannot be applied to non-class type
  • Index(es):
    • Date
    • Thread