iOS Development Interview Questions | iOS Development for Senior Developers
Summary
TLDR本次视频访谈的是David, 一个有6年开发经验的iOS开发人员。他谈到了WWDC会议上Apple公布的最新iOS 16功能,如锁屏小部件、实时活动更新和动态岛等。他还详细讨论了iOS开发中的并发、性能优化和测试的最佳实践。总的来说,这是一次对iOS开发及其最新趋势和技术的详尽而生动的概述。
Takeaways
- 🍏 WWDC是苹果的全球开发者大会,介绍iOS新功能,如SwiftUI的新导航API、锁屏小组件和实时活动。
- 🔑 Live Activities允许用户从锁屏实时更新应用信息,如共享出行应用状态或实时比分。
- 📱 David Zampier专注于iOS开发超过四年,参与了多个有趣的项目,如世界范围的行李追踪和流媒体应用。
- 💼 通过Touring工作,David得以与来自不同文化和国家的人交流,并为一家位于加州的公司工作。
- 🔄 Objective-C不再是新项目的首选,Swift和SwiftUI更受欢迎,但Objective-C代码仍可与Swift互操作。
- 📲 在苹果生态系统中,不同设备(如iPhone、Apple Watch、Apple TV)可以共享Swift代码,但需要不同的bundle ID。
- 🔗 Deep Link和Universal Link允许用户直接从网页或其他应用跳转到应用的特定页面。
- ⚙️ GCD(Grand Central Dispatch)和操作队列是iOS中实现并发的方式,允许后台执行多任务。
- 🧩 设计模式,如MVC和MVVM,对于构建易于理解和扩展的iOS应用至关重要。
- 🔍 TDD(测试驱动开发)是提高代码质量和结构的重要实践,通过先编写测试再编写功能代码来实现。
- ✨ 异步编程和最新的async/await关键字简化了iOS中并发任务的处理,提高了代码的可读性和维护性。
Q & A
WWDC是什么,今年有哪些新功能被介绍?
-WWDC是苹果的全球开发者大会,今年介绍了新的SwiftUI导航API、锁屏的新小工具、以及实时活动等功能。
锁屏上的实时活动是什么,它怎么工作?
-实时活动允许应用在锁屏上显示实时更新信息,如共享出行应用或实时比分等,也支持在iPhone 14 Pro和Pro Max的动态岛上显示。
如果我有自己的API,能在锁屏上显示数据吗?
-可以,你的应用可以通过实时活动在锁屏上显示来自你自己API的数据。
Objective-C还在iOS开发中使用吗,还是已经完全转向Swift?
-新项目和新功能主要使用Swift和SwiftUI,但因为Objective-C与Swift的良好互操作性,旧项目仍可能使用Objective-C。
iOS, watchOS, tvOS和macOS应用开发中有什么共同点?
-这些平台都可以使用Swift进行开发,并且开发者可以在这些平台间共享代码。
什么是深度链接,它如何工作?
-深度链接是指向你应用内特定页面的链接。使用通用链接,如果应用未安装,用户点击链接会被引导至App Store下载应用,安装后打开特定页面。
什么是GCD,它在iOS中用来解决什么问题?
-GCD(Grand Central Dispatch)是一种低级API,用于在iOS应用中实现并发和并行任务处理,通过管理后台线程来执行多个任务。
iOS应用在后台运行时会发生什么?
-当应用处于后台时,主线程被挂起,但后台线程可以继续执行某些操作,如使用用户位置或与服务器同步,但不能执行大量的处理任务。
App ID和Bundle ID有什么区别?
-Bundle ID是应用在苹果生态系统中的唯一标识符,而App ID是由团队ID和Bundle ID组成的字符串,用于标识同一开发团队的一个或多个应用。
在iOS开发中如何提高应用性能或管理内存?
-可以通过使用多线程、并发任务、懒加载属性等技术来提高性能和优化内存使用。
Outlines
😀 开场与iOS开发简介
视频以介绍主持人Jose和嘉宾David Zampier开始,David在iOS开发领域拥有超过六年的经验,专注于iOS开发近四到五年。讨论内容围绕David在iOS开发中的经验,特别是他参与的项目,如全球行李追踪、流媒体应用和社交网络应用。接着讨论了苹果的全球开发者大会(WWDC),David详细介绍了WWDC期间苹果发布的新iOS版本的新功能,如新的导航API、锁屏小工具、实时活动以及如何将这些新特性集成到自定义应用中。
🔄 iOS开发进阶话题
在这一部分,David讨论了iOS开发的更高级话题,包括Objective-C与Swift的使用情况、重要性和转变,以及开始iOS开发的最佳路径。他还详细解释了为不同苹果平台(如Apple Watch、Mac和Apple TV)开发应用时代码共享的概念。此外,他提到了深度链接(Deep Link)和大中心调度(GCD)在iOS中的应用,以及如何实现并发性和应用性能优化的技术。
🔍 iOS并发编程与性能优化
第三段深入探讨了iOS中的并发编程和性能优化策略。David解释了不同的并发技术,如调度队列、线程和操作队列,以及它们如何帮助提高应用性能。他讨论了将应用置于后台时的行为,包括何时使用用户位置和API同步,以及应用在后台的存活时间。David还区分了应用ID和包ID的概念,并提供了关于如何在不同的Apple平台上设置和识别应用的建议。
🛠️ iOS开发技巧与最佳实践
在这部分,David分享了有关iOS开发的技巧和最佳实践,包括如何使用懒加载属性来优化性能和内存使用,设计模式的重要性,特别是MVC和MVVM在iOS中的应用。他强调了测试驱动开发(TDD)的价值,并讨论了如何使用异步编程和完成处理器来处理iOS应用中的并发任务。David还提到了Swift中的async/await关键词,以及如何利用它们简化异步编程。
📲 iOS开发资源与学习路径
最后一段讨论了成为iOS开发者的资源和学习路径。David鼓励观众利用互联网上的资源,如Apple的官方文档和开发社区,来学习iOS开发。此外,他提出了动态派发和同步与异步任务的概念,并解释了它们在iOS应用开发中的区别和应用。视频以鼓励观众订阅频道并关注社交媒体账号结束,同时强调Touring平台上远程工作的机会。
🎉 结语与呼吁关注
在视频的结尾,Jose感谢David的精彩对话,并邀请观众订阅频道、点赞视频,并关注Touring在LinkedIn、Instagram、Facebook、Twitter、Clubhouse和YouTube上的社交媒体账号。强调了Touring提供的远程工作机会,鼓励有志于iOS开发的观众利用这个平台寻找合适的工作。
Mindmap
Keywords
💡iOS
💡Swift
💡WWDC
💡动态调度
💡异步
💡gcd
💡设计模式
💡测试驱动开发
💡内存管理
💡深度链接
Highlights
苹果每年在WWDC大会上发布iOS最新版本和特性
iOS 16增加了锁屏小组件功能,开发者可以为用户自定义锁屏
iOS 16还增加了实时动态信息更新功能,可以在锁屏显示比赛分数或者共享汽车等实时信息
WWDC大会上,开发者可以与苹果工程师交流,学习新特性和新文档
目前iOS开发都使用Swift语言,尽管Objective C仍然支持与Swift的互操作
SwiftUI可以编写跨多平台代码,比如iOS, watchOS和tvOS
深度链接可以直接打开App中的某个界面
GCD是底层API,可以同时执行并发任务
后台任务会被挂起,但是可以继续执行某些操作,比如位置跟踪
iOS有调度队列、线程和Operation Queues三种实现并发的方式
延时属性可以根据需要延迟初始化,提高性能
MVC设计模式还是常用的iOS架构模式
测试驱动开发可以提高代码质量
动态调度是在运行时决定调用哪个方法实现的
同步任务会顺序执行,异步任务同时开始
Transcripts
[Music]
hello everyone we are back with another
round of touring Dev talks and today I'm
so excited because today talks is about
iOS development and I will be talking
with David zampier about iOS okay and uh
to give you a little bit of context
about David has over six years of
experience but for the past four to five
years he's focused on iOS development so
without further Ado hi David D how are
you doing and how is your day doing so
far
hey Jose thank you for having me I'm
really excited to be here today talking
to you about the iOS development so yeah
this is uh I'm doing great thank you and
let's talk about it nice so could you
please uh introduce yourself and talk a
little bit about your experience with
iOS what kind of project have you been
doing
so yeah I've worked for a lot of uh
interesting projects like uh worldwide
baggage tracking like for lost baggages
in airports also for streaming apps
um and social networks so yeah
so cool project a lot of cool projects
nice nice all right so and the first
question that I have to you today is
what is WWDC and what happened there
oh yeah so wwc is the worldwide
developer conference it's a conference
that Apple uh where Apple shows all the
new features for the new iOS version it
happens on June it's a whole week of
stockings and we can talk with uh
airport Engineers we can
study the new documentations we have
some uh working sessions and
where Apple introduces the new features
for us developers so this year we had
like the new Apple announced the newer
navigation API for Swift UI so we can
like build the navigation for our apps
in Swift UI more easily so we have the
new widgets for lock screen so if you
are using the new iOS 16 you can you
probably have seen it and you can like
uh build
um custom widgets for the lock screen uh
us as developers so also we have the
live activities and like screen lock
screen as well and all of these features
were introduced by Apple in www.dc this
year and and they like
um touch taught us how to build them for
our custom apps nice nice and what is
live activities on lock screen what kind
of features we have there
okay so a lot of activities uh Apple
introduced this year so basically we can
you can see uh real-time updates from
your app from your locked screen so like
for Rideshare apps or
um some you can see the score of a live
game in your lock screen so it's really
interesting and also it worked in the
dynamic Island introduced by Apple in
the new iPhone 14 pro and 14 pro Max
and so if I have my own API can I I see
data in my lock screen from my own API
sure for sure yeah you can do it in your
app all right so that is amazing so
could you please tell our audience uh
how you're working at touring has been
so far
oh it's it has been amazing like I've
known people from many cultures from
many countries and this is great because
I have opportunity to connect to people
from all the world
and uh I've been working for a company
based in California and they are amazing
they have like great Engineers there and
I had opportunity to be there a couple
of weeks ago to know the the the company
uh headquarters and to connect to my
teammates and it was awesome did you
travel to us last last week also yeah
yeah all right that's amazing yeah
that's that's so nice all right so in
talking about iOS okay the first
question that I have for you is so I use
iOS I used to develop for iOS long uh
years ago long time ago and I use
Objective C okay and is objective c is
still using nowadays or they are using
only Swift
yeah so for new features and new
projects we are only using Swift and
sf2i maybe but because uh objectivity C
has a great interoperability with swift
so if you have like a code reading like
a few years ago you can like it
communicates with Swift in a great way
so we're not using objectives anymore
just for like old projects but we are
still migrating from your objectivity to
serve because it's way better in my
opinion nice and yeah and do you think
that it's important for developers to
know objective see if they want to start
in this world or they they must start
with Swift and then go on
I think they can start with swift
nowadays because as I said they're like
the new projects and the new features
that we're current building like they
are all in Swift but there are some
projects that still use this objectivity
so maybe at some point they will need to
like study a little bit about
objectivity but for starters I think
it's probably the best way to start with
swift just to understand a little bit
right
yeah all right all right all right so
um could you please
um explain me okay what what are the
main difference between uh you create
one application for Apple watch for Max
and for Apple TV and for iOS and so on
for example
yeah so uh basically we can use apple
uses Swift for all of its platforms like
uh iOS that it's the the OS for the
iPhones for watch OS for app watch the
TV OS that it is for Apple TV so
basically we can like for iOS we can
build an app for iOS and it can run
share the code with the Apple watch or
the iPads or even with the Mac OS so we
have great uh things
um a great ways to like share the code
between all the platforms from Apple
nice really nice all right and what
could you tell me about uh deep link uh
in iOS what's deep link
well so deep links uh there are links
that are used to send users like direct
to a point of your apps for screen or
something like that so
um
Apple introduced us the universal links
that's a new approach to connect your
web page
so we are uh to our app under the same
link so if you click to a universal link
and your app was set up with this new
this new Universal link API so instead
of if you don't have that installed on
your iPhone you'll be redirected to your
like the App Store so you can download
the app and open the app right on the
page that you are looking for that's
nice so let's suppose I am on touring
webpage website and then to the says uh
download our app and then when I click
in this link it will try to it will
check if I have this uh app installed in
my device if not it will redirect to uh
Apple Store in the app page when I click
and download it will download and open
the the app is that
yeah yeah basically that it's amazing
nice all right next question I have for
you okay uh what is gcd uh gcd and iOS
in general
okay so DCd stands for Grand Central
Dispatch it's a low level API that
enables users to run concurrent tasks
like a current
simultaneously by managed tradings
threatens in the background so today we
have uh lots of complex apps that needs
to run simultaneous tasks so the the gcd
it's a apple solution to build the
concurrency and parallelism into iOS
applications and so you can run multiple
tasks in background simultaneously and
this will not affect like the main
thread or your main app so you can still
using like your features while other
things are currently are happening in
the background
all right okay got that but
um so how we can achieve uh concurrence
in iOS so is that the only way to do
that or there's or is there any other
possibility
okay so basically we have three ways to
achieve the concurrency so one of them
are the dispatch queues so they are used
to manage uh tasks like my fifth order
first in First South where they can
basic execute it sequentially or
concurrently this is an easy way to
handle a secret a synchronous tasks in
your application you know so the second
way we can use threads so we can start a
thread and like uh run a code in this
separated thread and it will run uh
concurrently with the main traged that
of that or your app can have like many
threads
and having a threat is special it's
useful uh when you need to perform uh
some tests that it will take a long time
to to run you know
and we have also the operation skills
the operation queues they are high level
abstractions they were built on top of
the gcd that we talked before and it is
possible to
execute tasks like concurrently just
like this the gcd but in object-oriented
manner
all right so then I have two dummy
questions for you okay I hope you don't
kill me about this question but yeah so
first question
um what happened when you put our app in
background for example if I'm using 2D
app and then I just uh swiped up and
then go to the main page what what what
happened and what what can I do there
okay so basically when you put your app
and background uh the main thread it's
like suspended and the background
threads can uh perform some actions that
you are explicitly say to perform so you
can uh continue using the user's
location for Rideshare apps uh in
instance so also you can have like some
kind of synchronization with your
um background back end or if you or with
your API but you cannot perform like
have your uh have tasks like that
demands among a lot of power or energy
or processing from your app from the iOS
you know yeah and how much time our web
can stay in the background
so it's defined by the iOS the iOS
defines how much time your app can stay
alive in background
it depends on your available memory the
processing the app that is currently in
the in the foreground like is running
uh active at the same at the time you
know so it's defined by the iOS all
right in my second question for you is
what's the difference between app ID and
bundle ID
okay so the bundle ID is uh it's the
unique identifier for applications in
the whole apples ecosystem so we have
the bundle identifier for your IOS app
the bundle identifier for your
uh watch OS app for your Apple TV app so
they are for the whole Apple system uh
they use it they are used to reckon just
to recognize your app and for updates
and this kind of stuff and the app ID
it's a string that uniquely identifies
one or more apps from the same
development team so we have uh
development teams for the Apple
developer and uh this string the app ID
has two components the team ID and your
bundle ID from your app
got you so so if you have one
application that runs in my my cell
phone and another one that runs my Apple
watch so how can I set up it and to
identify they are the same
yeah so we will need to set a different
bundle identity a different bundle
identifier for your iOS targets we call
it Target so we have the iOS Target and
the watch West Target so we you can set
them separately different they must have
differently okay bundle with two
different bundle ID and when it comes to
the app ID
two different two
yeah exactly because you get the bundle
ID and the team ID the team ID will be
the same but the bundle ID will be
different all right so in terms of
performance uh what techniques we can
apply in our app to improve the
performance or the user the the managing
memory and stuff like that in our
application
okay so well we can do a lot of things
while we are creating a new feature
developing our code so we can use like
uh multiple threads I start processing
different threads or background threads
so we can do uh some hard work uh in the
background or if you have to do lots of
API calls you can use uh
simultaneously using concurrency also
you can use uh lady prop lazy properties
and a lot of
stuff nice nice and speaking about lazy
property what's lazy property
okay so the latest properties are
properties who's the initial value isn't
computed until the first time they are
used so you just need to include a lady
a lazy a modifier to your Declaration of
your property and this lets uh this will
delay the initialization the
initialization of this property so this
is a a good thing to
save your memory or save energy because
if you have a property that needs to do
some kind of uh uh work hard work or you
can reduce this unnecessary work like
you know so it will be computed just
when you use it in your code your call
it your function or something like that
nice nice all right and when it comes to
design pattern okay do you think design
patterns are important nowadays if so
what design pattern are they using and
if not what should they do
okay so I think design patterns are
really important for most uh all the the
software development because it allows
us to uh make our code more
understandable and you can add more
features in an easy way
and specifically for iOS development you
can use a lot of different design
patterns
um so
when for the UI kids apps uh Apple
always like tried to use the MVC the
model of your controller uh it's where
we can like have mainly three components
like the view uh the controller and the
model
um the view is what the user sees uh the
controller it's everything that controls
this view or get information for it and
the model are your models for your app
and
we have the mvvm that's commonly used
for the new Swift UI where we have the
model view the model where the model is
are the models from your app the view is
what your user sees and the view model
is what connects your view
to your model that's why it's called
view model but for iOS we can use lots
of other design patterns like Singleton
uh Builder and many others got you and
when it comes to testing okay what are
the best practice in terms of testing
your application
is DDD bdd any of this design pattern or
these techniques use it or is there
another one that you recommend
oh yeah so tdd is really important to
use I think in my opinion because it
allows us to plan the features and build
the features already with your tests so
basically we will we start developing
your feature by the test so you create
your tests let them fail because you
don't have your classes yet so and then
you implement your code and you run the
test and if your test passes you can
improve your code and this is amazing
because uh we can gain sites into both
quality of the implementation if it is
work and the quality of design if it's
well structured and it's a good a good
code that you have reading you know all
right yeah I totally agree with you so
tdd is really important not only to
debits as much as you test your
application you will avoid further
problems believe me yeah all right and
and the next thing that come to my mind
is to talk about complexion handle okay
uh what's completion Handler
well uh completion hinders uh are
basically just functions passed as
parameters to other functions so they're
using to dealing with response of a
synchronous task since we we do not know
like when it will end so we use a
completion Handler to perform uh an
actual after your asynchronous code was
uh uh was run and but now we have the
new synchronous uh the swiftest
synchronous API that we they introduced
the async uh await keywords where you
can like uh using them you don't need to
use the completion handles anymore nice
yeah it's pretty uh pretty similar what
they are doing with uh c-sharp and
JavaScript as well so you can just think
a way to introduce that in JavaScript
and that's pretty great all right and
before we go to our next question I
would like to open our developers out
there and if you have three places of
experience and they are confident with
your text tag go to touring.com I'll put
the link into the description section
below okay go to touring.com create your
profile there search for the job that
are suitable for your text tag and when
you find it you can apply for that all
you need to do is pass in the touring
fetching process once you complete
everything process you get a job 100
remote and as we did okay if you enjoyed
this content please consider to give a
big fat thumbs up for this video and
comment down below uh what kind of talks
you would like to have uh to see in the
upcoming video if you are not subscribed
subscribe to our YouTube channel uh
clicking in the bottom below and come
back to you David what do you understand
okay what could we tell us about Dynamic
dispatch
okay so in simple terms Dynamic dispatch
means that the program designs decides
at the runtime
which implementation of a particular
method or function it needs to invoke in
the case where a subclass overrides a
methods or if it's upper class Dynamic
dispatch there means determines whether
to invoke the subclass implementation
of the method are the parents it takes
more time like it it makes your code a
little bit slower using the dynamic
dispatch okay so previously we talked
about async await right which were a
great addition in iOS developing the iOS
world and so but I think I wait is for
uh can I say for asynchronous operations
or asynchronous tasks right but uh if
they are starting with iOS from now okay
from this video what do you understand
about the difference between synchronous
and asynchronous tasks in iOS how can we
explain it to our audience
okay uh so for synchronous tests uh they
are performed one at a time therefore uh
other tests must wait until the previous
task is completed before continue
for a synchronous tasks there runs
simultaneously in the background so if
the if background texts are completed
you'll be notified and a synchronous
programming allow us to process mood
proquests at the same time so you can
accomplish more tests in a shorter
amount of time you know okay let me see
if I get that so uh synchronous tasks
means it will be executing in the main
thread and then it go one by one let's
suppose you have a table uh with 10
lines and then you want to uh iterate
over this table it will be executing the
main thread and you go for line one and
then do whatever we need to do then line
two then line three line four and then
so on correct but asynchronous means
that it will be executed in a different
thread or the same thread as well
because this is I'm a bit confused so
different threads and then I can go for
uh execute that I can read the 10 lines
at the same times in different in in 10
different process and when it process
each process finish it will send me a
message is it like that
okay so the synchronous test not
necessarily will be
um uh run in the main thread I mean you
can start like a synchronous synchronous
tasks in a background thread so it is it
is possible and for the a synchronous
test they are start they start at the
same time I mean like one doesn't one
test don't need to wait to the other
test to finish so all of them start at
the same time in different queues and we
can like start for all of them to finish
to continue our code you know you can
get notified when all of them are
finished oh got you so then I have
follow-up questions so we wait we will
be notified when all of them uh finish
processing or one when each one so if
you want finish we will be notified and
then another one thing to be notified
you can have both behaviors it depends
on your implementation but you can get
that fire when all of them are completed
or when a specific one is completed nice
all right yeah you clarify my mind thank
you all right and as that said that was
my last question and then I just want to
ask you if you have anything to add okay
uh resource did that if they are
inspiring to be a iOS Developer like you
and work at tutoring where they can
learn uh what they could learn about iOS
what what's the best place to learn
about iOS well so we have a lot of uh
things on the internet so I mean we have
the Apple documentation we have a lot of
great uh blogs like uh talking about iOS
development so they are great resources
for us to understand and to learn about
iOS development in general in the
community community is really great you
know with this we come to the end thank
you Dave for this amazing talk okay that
was my pleasure to talk with you today
oh thank you Jose it was a pleasure uh
being here today talking to you thank
you for everything
cool I hope to see you again soon okay
and to everybody else so don't forget to
subscribe to our Channel okay hit the
button below and give us a big fat
thumbs up if you enjoyed this video and
don't forget to follow today on LinkedIn
Instagram Facebook Twitter Clubhouse
YouTube so we are in everywhere so keep
close to touring then I'm pretty much
sure that we'll get the job that you
deserve okay as that said that's a wrap
thank you and hope to see you all again
take care foreign
[Music]
5.0 / 5 (0 votes)