Explanation about correct use of the functions

Hello people!

I'm new with xCode - Swift and I wonder where I can find the explanations about the correct use of the functions or methods that are described in the documentation.

For example, if I see the next:

var rootViewController: UIViewController? { get set }

or:

func performSegue(withIdentifier identifier: String, sender: Any?)

I'm seeing this functions in the documentation but I cannot understand how implement them, is there some documentation with examples and more detailed explanations?

Thank you all.

Ernesto Reides.

You will find a lot of tutorials (www . raywenderlich.com is a good source, e.g., https://www.raywenderlich.com/5055396-ios-storyboards-segues-and-more) on the web or in "The Swift programming language" ebook. Some explanation for those

.

var rootViewController: UIViewController? { get set }

This means that this property can be read (get) and written (set). You can then implement getter and setter if you need. Look in "The Swift programming language".

Some properties are read only, you would find only { get } in the definition.

.

func performSegue(withIdentifier identifier: String, sender: Any?)

is called to execute a segue. For instance, if you want to segue when tapping a button:

  • define the segue from the starting ViewController to the destination
  • give it an Identifier, such as "SegueToView":
  • call in IBAction
     @IBAction func theAction(_ sender: UIButton) {
          performSegue(withIdentifier: "SegueToView", sender: sender)
          // You may also call:
          // performSegue(withIdentifier: "SegueToView", sender: nil)
     }          

Thank you for your replay,

I think that is a misunderstanding here, I give the functions above only as some examples, my real question was: where in some Apple site I can observe the use of the functions / methods that we found in the documentation of Apple.

After studying from the book "Developing in Swift - Fundamentals" I started the "Developing in Swift -Data collections", I feel that there is some issues that I don't understand and may be I'll receive more information about if I can read more from examples of code from Apple. Because I do not found some site like that I was thinking that some one of this community can help with some link to some site of Apple.

Anyway thank you all.

Ernesto.

There is not such a general site. And effectively, documentation may be a bit short in some cases.

The best is to search for examples, posting the function signature in the seacrh text. Usually, you will find such examples, not necessarily from Apple (rarely).

You can however search here:

or

Thank you all for your kindly responses, in meantime and after a short struggle with my miss-understandings I finally solved the problem and the exercise is working well! I learned a lot from this "AppEventCount" exercise in the data collections book. Thank you Claude31, the first of the two last links seems to me a good reference or at least there is there links to more actual solutions.

I wish to all a nice day and thanks again.

Ernesto.

Explanation about correct use of the functions
 
 
Q