At this point, I want to pause and connect the code that
we've written thus far to an image we saw previously in the course.
Here we tried to divide the different parts of our app into three camps.
I also want to investigate our code and
find out why is this programming file called ViewController?
What do those words view and controller even mean?
The place where this conversation starts is with an acronym.
MVC, or model, view, and controller.
And what this is, is a way to design or
make software applications like the app that we are making.
Let's begin with what is a view?
Simply put, a view is what the user sees or
is what is really visual on the screen.
So in our case, that would be buttons like the microphone button and
labels like the recording in progress label.
If you look at the document outline, you will notice that the microphone button,
the recording in progress label,
the stop button, they all form a part of our view.
To highlight the view on our screen, I can change its background color.
I can simply slide out the utility area and change the background color.
Boom.
Done.
Then let's think about the model.
This refers to the data of our app.
Now, we do not have one explicitly defined just yet.
But when we record our audio in lesson four, that audio file, including the name
of the file, the date it was recorded, that will all become a part of our model.
And finally let's talk about the controller.
A controller, as its name suggests,
controls conversations between the model and the view.
In our case, that is the ViewController.swift file.
When a user presses on a button, like the microphone button,
the controller handles that using an action.
Also, when a controller wants to change something in a view, like show and
hide this recording in progress label, it uses an outlet.
Now, a valid question to ask at this point is, why do all of this?
Well, the most important advantage is that we
can separate the major components of our app.
This helps in building large apps and
in making changes to them at a later stage.
في هذه المرحلة، أريد الإيقاف بشكل مؤقت وإعادة الاتصال بالتعليمة البرمجية التي
.كتبناها حتى الآن لنصل إلى الصورة التي رأيناها في السابق في الدورة التدريبية
.وقد حاولنا هنا تقسيم مختلف أجزاء التطبيق إلى ثلاثة أجزاء
كما أريد أيضًا فحص التعليمة البرمجية
والتعرف على سبب كون ملف البرمجة هذا يسمى ViewController؟
وماذا تعني كلمتا العرض ووحدة التحكم؟
.والمكان الذي تبدأ فيه هذه المحادثة باختصار
.وهو MVC أو النموذج والعرض ووحدة التحكم
وهذه هي طريقة لتصميم
.أو عمل تطبيقات برمجيات مثل التطبيق الذي نحن بصدد عمله
لنبدأ إذًا بالتعرف على معنى كلمة العرض؟
العرض بكل بساطة هو ما يشاهده المستخدم
.أو ما يكون مرئيًا بالفعل على الشاشة
إذًا ففي حالتنا، يكون ذلك في صورة أزرار مثل زر الميكروفون وتسميات
.مثل تسمية التسجيل قيد التقدم
وفي حالة النظر إلى المخطط التفصيلي المستند، ستلاحظون أن زر الميكروفون
،وتسمية التسجيل قيد التقدم
.وزر الإيقاف جميعًا تُكون جزءًا من العرض
.ولإبراز العرض على الشاشة، يمكنني تغيير لون الخلفية
.حيث يمكنني ببساطة تمرير منطقة الأداة المساعدة للخارج وتغيير لون الخلفية
.بووم
.Done
.لنفكر إذًا حول النموذج
.يشير هذا إلى بيانات تطبيقنا
.والآن ليس لدينا نموذج معرف بشكل صريح حتى الآن
لكن عندما نسجل الصوت في الدرس الرابع، فإن ملف الصوت، شاملاً اسم
.الملف، وتاريخ تسجيله، سيكون جزءًا من النموذج
.وفي النهاية دعونا نتحدث عن وحدة التحكم
،وحدة التحكم، كما يوضح الاسم
.تتحكم في المحادثات بين النموذج والعرض
.وتكون هنا عبارة عن ملف ViewController.swift
فعندما يضغط المستخدم على زر ما، كزر الميكروفون، تعالج وحدة التحكم
.ذلك باستخدام أحد الإجراءات
وأيضًا عندما تحتاج وحدة التحكم إلى تغيير شيء ما في طريقة العرض، كإظهار
.تسمية التسجيل قيد التقدم هذه وإخفائها، فهي تستخدم مخططًا
والآن يوجد سؤال وجيه يلزم طرحه في هذه المرحلة وهو، لماذا كل هذا؟
حسنًا، أهم ميزة في هذا هو أنه يمكننا
.فصل المكونات الرئيسية للتطبيق
وهذا يساعد في إنشاء تطبيقات كبيرة
.وعمل التغييرات عليها في مرحلة لاحقة
Neste ponto, quero fazer uma pausa e relacionar o código que
escrevemos até agora a uma imagem que vimos anteriormente no curso.
Aqui tentamos dividir as diferentes partes do nosso aplicativo em três campos.
Também quero investigar nosso código e
descobrir porque este arquivo de programação se chama ViewController.
O que essas palavras "view" e "controller" significam?
Essa conversa começa com uma sigla.
MVC, ou modelo, view e controlador.
E isso é uma maneira de projetar ou
fazer aplicativos de software como o que estamos fazendo.
Vamos começar com o que é um view?
Simplificando, a view é o que o usuário vê ou
o que é realmente visual na tela.
Portanto, no nosso caso, seriam botões como o botão de microfone e
rótulos como o de gravação em progresso.
Se você olhar o esboço do documento, notará que o botão do microfone, o rótulo de
gravação em progresso e o
botão de parar fazem parte do nosso View.
Para destacar a exibição na nossa tela, posso mudar a cor de fundo.
Posso simplesmente abrir a área de utilitário e alterar a cor de fundo.
Pronto!
Pronto.
Então, vamos pensar sobre o Modelo.
Ele refere-se aos dados do nosso aplicativo.
Ainda não temos um modelo explicitamente definido.
Mas quando gravarmos nosso áudio na lição quatro, esse arquivo de áudio, incluindo o nome
do arquivo, a data em que foi gravado, tudo isso vai se tornar uma parte do nosso modelo.
E, finalmente, vamos falar sobre o Controlador.
Um controlador, como o nome sugere,
controla as conversas entre o modelo e a view.
No nosso caso, ele é o arquivo ViewController.swift.
Quando um usuário pressiona um botão, como o botão do microfone,
o controlador lida com isso usando uma ação.
Além disso, quando um controlador quer mudar algo em uma view, como o rótulo mostrar e
ocultar esta gravação em progresso, ele usa uma saída.
Agora, uma pergunta válida a ser feita neste momento é por que tudo isso?
Bem, a principal vantagem é que
podemos separar os componentes principais do aplicativo.
Isso ajuda no desenvolvimento de aplicativos e
nas alterações deles numa fase posterior.