Protocol-Oriented Programming is a new programming paradigm which is used by Swift. In the Protocol-Oriented approach, we start designing our system by defining protocols then the protocol extensions, protocol inheritance, and protocol compositions which allow us to add a new functionality not only to one type, but to a whole collection of types that all conform to the same protocol.
The value types in Swift like struct or enum cannot inherit from other structs or enums which means we cannot use inheritance with value types, but the value types can inherit from protocols, even multiple protocols which is the most powerful feature of Swift which gives us much reuse and less redundancy of the code. …
AVFoundation is a multimedia framework with APIs in Objective-C and Swift which provides high-level services for working with time-based audiovisual media and combines six major technology areas which will go through each one in more details up and running, so let’s start with the first area in this article:
songURL
for the audio which wanna play.player
and hold the reference of AVAudioPlayer
because if we don’t have a reference, the player will be deallocated and can’t play the audio. …Before starting playing, streaming, recording sounds or configure how your application and the operating system should respond to the interruptions, we need to take a small journey to the Core Audio and some definitions about the audio just to get the full picture. In the next parts will talk in more details up and running.
Core Audio is the digital audio infrastructure of iOS and OS X. It includes a set of software frameworks designed to handle the audio needs in your applications which is optimized for the computing resources available in a battery powered mobile platform.
Core Audio uses the notion of proxy objects to represent such things as files, streams, audio players, and so on. When you want your application to work with an on-disk audio file, for example, the first step is to instantiate an audio file object of type AudioFileID
which is declared as an opaque data. …
I do love Music. It’s part of my life, I listen to it while I am coding, doing sports or even while cooking 😄. So I decided to explore Audio frameworks in more details on iOS and I would love to start by how we can play a song like SoundCloud do and here’s the final demo of the tutorial.
Will talk about how we can use Apple Combine with Core Data but if you like to read more about Core Data itself and how can we use it to save, fetch and delete the entities you can read the previous article about Core Data with Sugar Syntax.
First we will need to create a custom Combine Publisher and fortunately it’s super easy to do that we will need just 3 steps to do it but before doing that we need to understand how the publisher actually work, so let’s talk about that for a bit before applying our customer Publisher to the Core Data and we need to understand the Publisher
, the Subscription
and the…
When I started iOS programming since years ago I was mixing up between the Core Data and the Database, but in fact the Core Data is not a database even Core Data is actually backed by an SQLite database but both of them are ways of providing searchable and persistent storage. In short description we can say that SQLite is a database itself and Core Data is an ORM (Object Relational Model) which creates a layer between the database and the UI.
Core Data is a framework that you use to manage the model layer objects in your application. It provides generalized and automated solutions to common tasks associated with object life cycle and object graph management, including persistence. It typically decreases by 50 to 70 percent the amount of code you write to support the model layer and to well understand the Core data and how it works we need to understand the Core Data Stack. …
In Part 1 talked about what’s Combine and how we can understand and use it and in Part 2 talked about more examples of the usage.
Now let’s leverage what we have learned and apply into real examples.
NSObject
and the property should be@objc dynamic
.In Part 1 talked about what’s Combine and how we can understand and use it and in this part will go continuing the examples of the usage.
a is: 1 b is: 4
a is: 2 b is: 4
a is: 0 b is: 4
a is: 3 b is: 4Value is: 4
Value is: A1
Value is: A2
Value is: B1
Value is…
The Combine framework provides a declarative Swift API for processing values over time. These values can represent many kinds of asynchronous events. so in an imperative programming setting a = b+c
would mean that a
is being assigned the result of b+c
, and later, the values of b
and c
can be changed with no effect on the value of a
, but in reactive programming, the value of a
is automatically updated whenever the values of b
or c
change, without the program having to re-execute the statement a:=b+c
to determine the presently assigned value of a
. Wikipedia
and to understand Combine so well we have to understand 3 main…
Have you ever pushed a commit on your branch and your commit did fail and then you fixed your commit and pushed again?
The solution to get rid of that is so easy and thanks for Git Hooks which offers pre-commit
for us which’s used to inspect the snapshot that’s about to be committed to see if you’ve forgotten something, to make sure tests run or to examine whatever you need to inspect in the code.
If you went deep in .git
folder you will find a lot of samples for the hooks. …
About