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

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

    Code:
    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

    http://i.stack.imgur.com/OyjNP.png
     
  2. JWalker1995 macrumors regular

    Joined:
    Mar 5, 2011
    #2
    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

    Joined:
    Mar 29, 2016
    #3
    Thanks you so much sir...
     
  4. tyche macrumors 6502

    Joined:
    Jul 30, 2010
    #4
    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

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

    http://stackoverflow.com/questions/...nction-type-element-aka-keyanyobject-valueany
     

Share This Page