Objective-C Default Argument Value

前端 未结 6 1753
广开言路
广开言路 2020-12-10 03:58

Hey there, quick question here. I\'m sure there\'s a simple answer.

Coming from PHP, I\'m used to declaring a function with a default argument value like this:

6条回答
  •  醉话见心
    2020-12-10 04:07

    No, default arguments are a feature of C++, not C or Objective-C.

    What you would have to do in objective-c is the following (using your psuedo code above):

    function myFunction ($array, $sort)
    
    function myFunction ($array)
    // call myFunction($array, FALSE)
    

提交回复
热议问题