Tutorial on closures in swift 4 for beginners

Поділитися
Вставка
  • Опубліковано 21 жов 2024

КОМЕНТАРІ • 33

  • @SevenDeMagnus
    @SevenDeMagnus 4 роки тому

    New subscriber here.

  • @TygruletZ
    @TygruletZ 5 років тому +3

    Finally I understood Closures ! Thank you so much !!!

  • @SevenDeMagnus
    @SevenDeMagnus 4 роки тому

    Cool thanks, are closures just used as an argument for a function that has a parameter of a closure?

    • @swifttutorialsforios
      @swifttutorialsforios  4 роки тому +1

      Yes, as most of the times they are associated like a completion handler, so that one can gets response or compiler attention during asynchronous call.

    • @SevenDeMagnus
      @SevenDeMagnus 4 роки тому

      @@swifttutorialsforios Thanks. What's an example of a synchronous call?

    • @swifttutorialsforios
      @swifttutorialsforios  4 роки тому +1

      Normalnfunctioms likenassigning image to UiImageview or text to uilable are examole of synchronous call

    • @SevenDeMagnus
      @SevenDeMagnus 4 роки тому

      @@swifttutorialsforios Thanks. In a real life analogy, is asychronous analgous to a gantt chart or say a chef frying something and while waiting for that to finish, he is chopping vegetables? Or are these two example analogous to synchronous?

    • @swifttutorialsforios
      @swifttutorialsforios  4 роки тому +1

      For example of real life suppose chef is heating oil in the pan, he starts chopping vegetable till oil heats up. This is asynchronous call as both task are not blocking each other. Thus if you want you use closure in this case you will say as soon as choping vegetables are done, we will put vegetables in oil.

  • @onyxion100
    @onyxion100 5 років тому +1

    That is the best explanation I have got by far - thank you so very much!!

  • @stalinathavan1043
    @stalinathavan1043 5 років тому +1

    thanks a lot finally

  • @manikanthag1066
    @manikanthag1066 5 років тому

    It is too good..plz share how to develop maps in IOS using mapkit and find track line between two locations..

  • @АлександрФедоров-п2й
    @АлександрФедоров-п2й 5 років тому +1

    Nice!

  • @saravananraju528
    @saravananraju528 5 років тому

    Closure as a completion handler Explain Please?

  • @niteshkumar2133
    @niteshkumar2133 5 років тому

    when we use closure instead of function and why?

    • @swifttutorialsforios
      @swifttutorialsforios  5 років тому +1

      In certain tasks where you does not the execution time or response back time, these are the cases where you need to use closures.

    • @niteshkumar2133
      @niteshkumar2133 5 років тому

      @@swifttutorialsforios can you explain it with the help of example.

    • @swifttutorialsforios
      @swifttutorialsforios  5 років тому

      Ok, i will try to make a video on same.

    • @shivaellandulavlogs7149
      @shivaellandulavlogs7149 5 років тому

      What is the escaping and non Escaping closures when to use these

  • @prithivi44
    @prithivi44 6 років тому

    Hi brother.. Really such a needling tutorial when you explained and compared it with function... I was struggling to understand it.. Thank you brother..and finally . Subscribed...

  • @lavanyaa6913
    @lavanyaa6913 6 років тому

    Hi, Nice tutorial. If possible can you upload database with dynamic data in swift.

    • @swifttutorialsforios
      @swifttutorialsforios  6 років тому

      Thanks for the feedback. Will try to create one video with same topic as soon as we can. Thank you

    • @lavanyaa6913
      @lavanyaa6913 6 років тому

      thank you.

  • @ahmadfaraz3678
    @ahmadfaraz3678 6 років тому

    What is trailing closure?

    • @ahmadfaraz3678
      @ahmadfaraz3678 6 років тому

      Swift Tutorials can you please make a tutorial on it.

    • @07Rajneesh
      @07Rajneesh 5 років тому

      when the closure passed as last parameter in a function (if that function has many parameters) called outside of the function . then that closure treated as trailing closure.

  • @niteshkumar2133
    @niteshkumar2133 5 років тому

    Can u explain why use closure instead of functions.

    • @swifttutorialsforios
      @swifttutorialsforios  5 років тому

      Thats not mandatory but it depends upon the requirement. Closures are useful because
      1) easy readability
      2) no need to remeber the reference for object for which closure gets called ( example suppose in tableview list you need to get name according to lat long from api. So if you use closures then its easy to set name for lable as the refrencw of each closures call is associated with the calling cell and in case of function you need to put a check to detect for which cell you fetch the name)