https://github.com/rodrigofrancisco/operationqueueexample
Example to show how to handle fetched data from REST API using OperationQueue instead GCD
https://github.com/rodrigofrancisco/operationqueueexample
example-code ios-swift
Last synced: over 1 year ago
JSON representation
Example to show how to handle fetched data from REST API using OperationQueue instead GCD
- Host: GitHub
- URL: https://github.com/rodrigofrancisco/operationqueueexample
- Owner: rodrigofrancisco
- Created: 2021-09-24T18:41:18.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-10-12T16:59:23.000Z (over 4 years ago)
- Last Synced: 2025-01-28T22:20:09.841Z (over 1 year ago)
- Topics: example-code, ios-swift
- Language: Swift
- Homepage:
- Size: 413 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
= Ejemplo de OperationQueue y Networking
Creado por Rodrigo Francisco
Version 1.0, 24.09.2021
// Ruta base de las imagenes
:imagesdir: ./README.assets/
// Resaltar sintaxis
:source-highlighter: pygments
// Iconos para entorno local
ifndef::env-github[:icons: font]
// Iconos para entorno github
ifdef::env-github[]
:caution-caption: :fire:
:important-caption: :exclamation:
:note-caption: :paperclip:
:tip-caption: :bulb:
:warning-caption: :warning:
endif::[]
Proyecto para el diplomado 5G iOS, módulo 3
[source,sh]
Septiembre de 2021
Autor: rhodfra@gmail.com
swift 5, iOS 13
El proyecto muestra como realizar una petición a un servicio REST,
para posteriormente manejar los eventos subsecuentes utilizando
`OperationQueue`, `Operation` y/o algún otro mecanismo.
Para ejecutar el proyecto simplemente descargue el repositorio y
ejecute el playground.
El core de este proyecto se encuentra en el archivo
link:./NetworkingWithOperation.playground/Contents.swift[Contents.swift]
image::cover.png[]
[source,swift]
----
// MARK:- Fetching information with NSOperations
let queue = OperationQueue()
// We will be using main operation Queue to update UI Components
let mainQueue = OperationQueue.main
var myImage: UIImage?
var metadata: ImageMetadata?
let operationForImage = BlockOperation(block: {
print("Started image download")
myImage = downloadImage(imageNumber: 1)
print("Finished image download")
})
let operationForMetadata = BlockOperation(block: {
print("Started download metadata")
metadata = downloadMetadata(imageNumber: 1)
print("Finished download metadata")
})
queue.addOperation(operationForImage)
queue.addOperation(operationForMetadata)
----