SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
New Features
in iOS 15 and
Swift 5.5


https://www.bacancytechnology.com/
Introduction
At Worldwide Developers Conference
21, Apple has overcome many
limitations by announcing some
important features for developers.
Apple has made sure while introducing
the new features in iOS 15 and Swift 5.5
that every developer can build the best
interactive applications with minimal
time and effort. In this blog post, we
will learn a few new features that have
been introduced and see how we can
implement them in our code.
New Features
in iOS 15 and
Swift 5.5
1. UISheetPresentation Controller
Apple provided some new API
improvements in WWDC 21 to present the
bottom sheets. In iOS 14, they introduced
this, but it didn’t have any customization,
but from iOS 15, we can implement apple
maps like a bottom sheet with a smaller
height. It has customization like height
adjustment, adding a grabber to the top of
the sheet.


UIViewController has a new property
called sheetPresentationController; you
can present the bottom sheet. We can
access the sheetPresentationController
property to get the instance of
UISheetPresentationController for
customizing its appearance.
@IBAction func openSheetAction(_
sender : UIButton) {
if let bSheet =
bottomSheet.sheetPresentationController
{
bSheet.detents = [.medium(),
.large()]
bSheet.prefersGrabberVisible = true
bSheet.largestUndimmedDetentIdentifie
r = .medium
bSheet.prefersScrollingExpandsWhenScr
olledToEdge = false
bSheet.preferredCornerRadius = 30.0
}
present(bottomSheet, animated: true,
completion: nil)
}
Here, we can use detents to adjust the
height of the bottom sheet. It has 2
values .large() & .medium(). .large() will
show height for full screen & .medium()
will occupy height of half of screen
height. Here, We have passed an array
for detents, so first, it will show in half
of the screen height & then we can drag
it up to the full screen.
Here, we added a grabber on top of the
sheet, so users can understand how to
drag it & drag it.
When the bottom sheet is presented, the
view behind it dims automatically; if you
want to prevent it, you can set the value
of largestUndimmedDetentIdentifier to
.medium.
bSheet.largestUndimmedDetentIdentifie
r = .medium


If your bottom sheet has scrollable
content, we can set
prefersScrollingExpandsWhenScroll
edToEdge to false so that it will
scroll without going down & using
grabber; you can drag the sheet &
show it in full screen.
bSheet.prefersScrollingExpandsWh
enScrolledToEdge = false
We can set the corner radius for the
bottom sheet also using
preferredCornerRadius.
bSheet.preferredCornerRadius =
30.0


Want to get dedicated and highly-
skilled iOS developers?
Contact the best mobile
development company: Bacancy,
to hire iOS developer and start
building brilliant mobile apps.
2. UIMenu:


iOS 14 introduced UIMenu, but if you
want to add a submenu, it was not
possible in iOS 14. So, iOS 15
introduced UIMenu with SubMenu
added to it.


Using UIMenu, we can create an
instance of the menu; it has a
parameter called children that can
take an array of UIMenu & UIAction.


UIAction takes the title, image,
attributes, state & handler as its
parameters.
UIMenu takes the title, image, options,
handler & other parameters. The state
in
UIAction is used to show a checkmark
to show selection.


It has 3 values .displayInline,
.destructive, .singleSelection. Using the
.singleSelection or .destructive option in
UIMenu, we can show the submenu.
When using .singleSelection It will allow
only 1 item as selected in the menu or
submenu.
@IBAction func menuAction(_ sender
: UIButton) {
let more = UIMenu(title: "More",
image: UIImage(systemName:
"ellipsis"), options: .singleSelection,
children: [
UIAction(title: "Share", image:
UIImage(systemName:
"square.and.arrow.up"), handler: { _ in
}),
UIAction(title: "Save", image:
UIImage(systemName: "folder"),
handler: { _ in }),
UIAction(title: "Edit", image:
UIImage(systemName: "pencil"),
state: .on, handler: { _ in })
])
let destruct = UIAction(title: "Delete",
image: UIImage(systemName:
"trash"), attributes: .destructive) { _
in }
let disable = UIAction(title:
"Standard", image:
UIImage(systemName: "sun.max"),
attributes: .disabled) { _ in }
btnMenu.menu = UIMenu(title:
"", children: [more, destruct, disable])
}
On long pressing the button, it shows the
menu; if you want to open the menu by
tapping the button, you can use the
property showsMenuAsPrimaryAction.


btnMenu.showsMenuAsPrimaryActi
on = true
3.CLLocationButton
In iOS 13, new location permission was
introduced to access it only once. So,
whenever a user tries to access the
location, it asks for permission. In iOS
15, Apple improved that feature. They
are providing location button UI by
default. So, the first time it will ask the
user for permission. Whenever users
open the app again, the user can simply
click on the location button & it will
give access to the current location
without asking for permission alert.


If the user has denied permission for
the first time, when the user clicks on
the location button next time, it will
give access to the current location
without asking for a permission alert.
Once the location access is granted, even if
the application is in the background, it will
get location data. Location data access will
expire once the user or system terminates
the app.
4.Async/Await:


Swift 5.5 introduced changes in the
concurrency system using
async/await. Concurrency means
running multiple chunks of code at
the same time. As the name suggests,
it is a way to write complex
asynchronous code if it is
synchronous. There are two steps to
perform for async/await: make a
function using the async keyword &
call it using await keyword. Async
means asynchronous; we can add it as
method attributes.
func generateRandomNumbers()
async -> [Int] {
(1...100).map { _ in
Int.random(in: 1...100)
}
}


To call this method, we need to use
await keyword ahead of the method call
& add it in an asynchronous context,
Task.
func showNumbers() {
Task{
let numbers = await
generateRandomNumbers()
print(numbers)
}
}
Before async/await was
introduced, we used closure
completion blocks, Result mostly
in Web service calls. From swift 5.5
onwards, We can use async/await
for asynchronous code without
completion handlers to return
values. We can directly assign
those values to
their respective variables. Using await
keyword in a function call will stop
further code execution until a response
comes.
To execute further code while
asynchronous code is executing, you
can keep the async keyword before the
variable & await the keyword while
accessing its result.
async let numbers =
generateRandomNumbers()
print(await numbers)
If we want to call multiple asynchronous
functions parallel, we can also do it with
async/await.
async let numbersInt =
generateRandomNumbersInt()
async let numbersDouble =
generateRandomNumbersDouble()
let numbers = await [numbersInt,
numbersDouble] as [Any]
print(numbers)


For error handling, in async/await, we
can use Result or try/catch.
let result = await
generateRandomNumbersInt()
switch result {
case .success(_):
break
case .failure(_):
break
}
do {
let result = try await
generateRandomNumbersInt()
print(result)
} catch let e {
print(e)
}
5. Double & CGFloat Interchangeable
Types:


From swift 5.5, You can use Double &
CGFloat interchangeably without
converting them.
You can perform operations on Double
& CGFloat & can get the result in
Double.


let varCgFloat: CGFloat = 40
let varDouble: Double = 80
let result = varCgFloat + varDouble
print(result)
Output::
6. Lazy in the Local Context


Lazy keywords allow us to define stored
properties that will initialize when first
time used. From Swift 5.5, you can now
use the lazy keyword in the local context.
func printGreetingMethod(to: String)
-> String {
print("In printGreetingMethod()")
return "Hey, (to)"
}
func lazyInLocal() {
print("Before lazy call")
lazy var greetingLazy =
printGreetingMethod(to: "jena")
print("After lazy call")
print(greetingLazy)
}
Output:
Conclusion
With the introduction of new
features in iOS 15 and Swift 5.5, the
application development became
less challenging with more robust
outcomes. The lightweight and
straightforward syntax with
powerful pattern matching has
made development better for iOS
developers.
Thank You
https://www.bacancytechnology.com/

Contenu connexe

Similaire à New Features in iOS 15 and Swift 5.5.pdf

Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outletsveeracynixit
 
Ruby motion勉強会 2012年7月
Ruby motion勉強会 2012年7月Ruby motion勉強会 2012年7月
Ruby motion勉強会 2012年7月Eihiro Saishu
 
Gui builder
Gui builderGui builder
Gui builderlearnt
 
Android, the life of your app
Android, the life of your appAndroid, the life of your app
Android, the life of your appEyal Lezmy
 
Easy job scheduling with android
Easy job scheduling with androidEasy job scheduling with android
Easy job scheduling with androidkirubhakarans2
 
How to create_your_own_android_app
How to create_your_own_android_appHow to create_your_own_android_app
How to create_your_own_android_appCharo Cuart
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhoneErin Dees
 
Angular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdfAngular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdfJohnLeo57
 
Creating an Uber Clone - Part I - Transcript.pdf
Creating an Uber Clone - Part I - Transcript.pdfCreating an Uber Clone - Part I - Transcript.pdf
Creating an Uber Clone - Part I - Transcript.pdfShaiAlmog1
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updatedGhanaGTUG
 
App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started GuideVasilis Drimtzias
 
Building interactive app
Building interactive appBuilding interactive app
Building interactive appOmar Albelbaisy
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1Hussain Behestee
 
Maps - Part 2 - Transcript.pdf
Maps - Part 2 - Transcript.pdfMaps - Part 2 - Transcript.pdf
Maps - Part 2 - Transcript.pdfShaiAlmog1
 

Similaire à New Features in iOS 15 and Swift 5.5.pdf (20)

Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
 
Project two c++ tutorial
Project two c++ tutorialProject two c++ tutorial
Project two c++ tutorial
 
Ruby motion勉強会 2012年7月
Ruby motion勉強会 2012年7月Ruby motion勉強会 2012年7月
Ruby motion勉強会 2012年7月
 
Gui builder
Gui builderGui builder
Gui builder
 
Android, the life of your app
Android, the life of your appAndroid, the life of your app
Android, the life of your app
 
Easy job scheduling with android
Easy job scheduling with androidEasy job scheduling with android
Easy job scheduling with android
 
Exploring iTools
Exploring iToolsExploring iTools
Exploring iTools
 
How to create_your_own_android_app
How to create_your_own_android_appHow to create_your_own_android_app
How to create_your_own_android_app
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
Angular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdfAngular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdf
 
Creating an Uber Clone - Part I - Transcript.pdf
Creating an Uber Clone - Part I - Transcript.pdfCreating an Uber Clone - Part I - Transcript.pdf
Creating an Uber Clone - Part I - Transcript.pdf
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
 
App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started Guide
 
Swift
SwiftSwift
Swift
 
Using android's action bar
Using android's action barUsing android's action bar
Using android's action bar
 
Building interactive app
Building interactive appBuilding interactive app
Building interactive app
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
Introducing Small Basic.pdf
Introducing Small Basic.pdfIntroducing Small Basic.pdf
Introducing Small Basic.pdf
 
Create New Android Activity
Create New Android ActivityCreate New Android Activity
Create New Android Activity
 
Maps - Part 2 - Transcript.pdf
Maps - Part 2 - Transcript.pdfMaps - Part 2 - Transcript.pdf
Maps - Part 2 - Transcript.pdf
 

Plus de Katy Slemon

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfKaty Slemon
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfKaty Slemon
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfKaty Slemon
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfKaty Slemon
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfKaty Slemon
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfKaty Slemon
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfKaty Slemon
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfKaty Slemon
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfKaty Slemon
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfKaty Slemon
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfKaty Slemon
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfKaty Slemon
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfKaty Slemon
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfKaty Slemon
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfKaty Slemon
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfKaty Slemon
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfKaty Slemon
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfKaty Slemon
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfKaty Slemon
 
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdfUncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdfKaty Slemon
 

Plus de Katy Slemon (20)

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdf
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdf
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdf
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdf
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdf
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdf
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdf
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdf
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdf
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdf
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdf
 
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdfUncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
 

Dernier

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Dernier (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

New Features in iOS 15 and Swift 5.5.pdf

  • 1. New Features in iOS 15 and Swift 5.5 https://www.bacancytechnology.com/
  • 3.
  • 4. At Worldwide Developers Conference 21, Apple has overcome many limitations by announcing some important features for developers. Apple has made sure while introducing the new features in iOS 15 and Swift 5.5 that every developer can build the best interactive applications with minimal time and effort. In this blog post, we will learn a few new features that have been introduced and see how we can implement them in our code.
  • 5. New Features in iOS 15 and Swift 5.5
  • 6. 1. UISheetPresentation Controller Apple provided some new API improvements in WWDC 21 to present the bottom sheets. In iOS 14, they introduced this, but it didn’t have any customization, but from iOS 15, we can implement apple maps like a bottom sheet with a smaller height. It has customization like height adjustment, adding a grabber to the top of the sheet. UIViewController has a new property called sheetPresentationController; you can present the bottom sheet. We can access the sheetPresentationController property to get the instance of UISheetPresentationController for customizing its appearance.
  • 7. @IBAction func openSheetAction(_ sender : UIButton) { if let bSheet = bottomSheet.sheetPresentationController { bSheet.detents = [.medium(), .large()] bSheet.prefersGrabberVisible = true bSheet.largestUndimmedDetentIdentifie r = .medium bSheet.prefersScrollingExpandsWhenScr olledToEdge = false bSheet.preferredCornerRadius = 30.0 } present(bottomSheet, animated: true, completion: nil) }
  • 8. Here, we can use detents to adjust the height of the bottom sheet. It has 2 values .large() & .medium(). .large() will show height for full screen & .medium() will occupy height of half of screen height. Here, We have passed an array for detents, so first, it will show in half of the screen height & then we can drag it up to the full screen.
  • 9. Here, we added a grabber on top of the sheet, so users can understand how to drag it & drag it. When the bottom sheet is presented, the view behind it dims automatically; if you want to prevent it, you can set the value of largestUndimmedDetentIdentifier to .medium.
  • 10. bSheet.largestUndimmedDetentIdentifie r = .medium If your bottom sheet has scrollable content, we can set prefersScrollingExpandsWhenScroll edToEdge to false so that it will scroll without going down & using grabber; you can drag the sheet & show it in full screen. bSheet.prefersScrollingExpandsWh enScrolledToEdge = false
  • 11. We can set the corner radius for the bottom sheet also using preferredCornerRadius. bSheet.preferredCornerRadius = 30.0 Want to get dedicated and highly- skilled iOS developers? Contact the best mobile development company: Bacancy, to hire iOS developer and start building brilliant mobile apps.
  • 12. 2. UIMenu: iOS 14 introduced UIMenu, but if you want to add a submenu, it was not possible in iOS 14. So, iOS 15 introduced UIMenu with SubMenu added to it. Using UIMenu, we can create an instance of the menu; it has a parameter called children that can take an array of UIMenu & UIAction. UIAction takes the title, image, attributes, state & handler as its parameters.
  • 13. UIMenu takes the title, image, options, handler & other parameters. The state in UIAction is used to show a checkmark to show selection. It has 3 values .displayInline, .destructive, .singleSelection. Using the .singleSelection or .destructive option in UIMenu, we can show the submenu. When using .singleSelection It will allow only 1 item as selected in the menu or submenu.
  • 14. @IBAction func menuAction(_ sender : UIButton) { let more = UIMenu(title: "More", image: UIImage(systemName: "ellipsis"), options: .singleSelection, children: [ UIAction(title: "Share", image: UIImage(systemName: "square.and.arrow.up"), handler: { _ in }), UIAction(title: "Save", image: UIImage(systemName: "folder"), handler: { _ in }), UIAction(title: "Edit", image: UIImage(systemName: "pencil"), state: .on, handler: { _ in }) ])
  • 15. let destruct = UIAction(title: "Delete", image: UIImage(systemName: "trash"), attributes: .destructive) { _ in } let disable = UIAction(title: "Standard", image: UIImage(systemName: "sun.max"), attributes: .disabled) { _ in } btnMenu.menu = UIMenu(title: "", children: [more, destruct, disable]) }
  • 16. On long pressing the button, it shows the menu; if you want to open the menu by tapping the button, you can use the property showsMenuAsPrimaryAction. btnMenu.showsMenuAsPrimaryActi on = true
  • 17. 3.CLLocationButton In iOS 13, new location permission was introduced to access it only once. So, whenever a user tries to access the location, it asks for permission. In iOS 15, Apple improved that feature. They are providing location button UI by default. So, the first time it will ask the user for permission. Whenever users open the app again, the user can simply click on the location button & it will give access to the current location without asking for permission alert. If the user has denied permission for the first time, when the user clicks on the location button next time, it will give access to the current location
  • 18. without asking for a permission alert. Once the location access is granted, even if the application is in the background, it will get location data. Location data access will expire once the user or system terminates the app.
  • 19. 4.Async/Await: Swift 5.5 introduced changes in the concurrency system using async/await. Concurrency means running multiple chunks of code at the same time. As the name suggests, it is a way to write complex asynchronous code if it is synchronous. There are two steps to perform for async/await: make a function using the async keyword & call it using await keyword. Async means asynchronous; we can add it as method attributes.
  • 20. func generateRandomNumbers() async -> [Int] { (1...100).map { _ in Int.random(in: 1...100) } } To call this method, we need to use await keyword ahead of the method call & add it in an asynchronous context, Task.
  • 21. func showNumbers() { Task{ let numbers = await generateRandomNumbers() print(numbers) } } Before async/await was introduced, we used closure completion blocks, Result mostly in Web service calls. From swift 5.5 onwards, We can use async/await for asynchronous code without completion handlers to return values. We can directly assign those values to
  • 22. their respective variables. Using await keyword in a function call will stop further code execution until a response comes. To execute further code while asynchronous code is executing, you can keep the async keyword before the variable & await the keyword while accessing its result. async let numbers = generateRandomNumbers() print(await numbers)
  • 23. If we want to call multiple asynchronous functions parallel, we can also do it with async/await. async let numbersInt = generateRandomNumbersInt() async let numbersDouble = generateRandomNumbersDouble() let numbers = await [numbersInt, numbersDouble] as [Any] print(numbers) For error handling, in async/await, we can use Result or try/catch.
  • 24. let result = await generateRandomNumbersInt() switch result { case .success(_): break case .failure(_): break } do { let result = try await generateRandomNumbersInt() print(result) } catch let e { print(e) }
  • 25. 5. Double & CGFloat Interchangeable Types: From swift 5.5, You can use Double & CGFloat interchangeably without converting them. You can perform operations on Double & CGFloat & can get the result in Double. let varCgFloat: CGFloat = 40 let varDouble: Double = 80 let result = varCgFloat + varDouble print(result)
  • 26. Output:: 6. Lazy in the Local Context Lazy keywords allow us to define stored properties that will initialize when first time used. From Swift 5.5, you can now use the lazy keyword in the local context.
  • 27. func printGreetingMethod(to: String) -> String { print("In printGreetingMethod()") return "Hey, (to)" } func lazyInLocal() { print("Before lazy call") lazy var greetingLazy = printGreetingMethod(to: "jena") print("After lazy call") print(greetingLazy) }
  • 30. With the introduction of new features in iOS 15 and Swift 5.5, the application development became less challenging with more robust outcomes. The lightweight and straightforward syntax with powerful pattern matching has made development better for iOS developers.