Cannot call value for non-function type element ('aka' (key:anyobject ,value:anyobject)..

Discussion in 'iOS Programming' started by Mane_ios, Mar 29, 2016.

  1. Mane_ios, Mar 29, 2016
    Last edited by a moderator: Mar 30, 2016

    Mane_ios macrumors newbie

    Mar 29, 2016
    How to resolve this error? I am new to programming and got totally struck with this error in all llines of code attached below

    videoObj.videoid = video("snippet.videoid") as! String
    videoObj.videoTitle = video("snippet.title") as! String
    videoObj.videoDescription = video("snippet.description") as! String
    videoObj.videoThumbnailUrl = video("snippet.videoid") as! String

    Error Screenshot
  2. JWalker1995 macrumors regular

    Mar 5, 2011
    Your using a 'Contructor' method to set a property. You either need to do obj.description = "my description"

    Or, having made a custom constructor
    ObjClass obj = ObjClass("id", "description", "title")

    I would recommend the second one.

    Note: excuse any small error, written on mobile and haven't studied swift massively
  3. Mane_ios thread starter macrumors newbie

    Mar 29, 2016
    Thanks you so much sir...
  4. tyche macrumors 6502

    Jul 30, 2010
    You're calling video and passing it garbage as far as I can tell. Maybe it's a constructor maybe it's a function, who knows. "snippet.videoid" is a string where I suspect you want to pass the value assigned to that string. In another line you pass in a string called "snippet, videoID" into video.

    If you're still having problems, it would be better to post the code, in particular the video(...) section.
  5. Mane_ios thread starter macrumors newbie

    Mar 29, 2016
    @tyche thanks a lot for responding,please find the code below:

Share This Page

4 March 29, 2016