- Support for multiple platforms in the same framework.
- Support for Swift, Objective-C and C.
- Support for dynamic frameworks and static libraries.
- Support for Swift Package Manager.
- End of fat binaries.
- Open Current framework project
struct TaskExample: View { | |
@State private var source = "" | |
var body: some View { | |
ScrollView { | |
Text(source) | |
} | |
.task { | |
await fetchSource() | |
} | |
} |
// Swift Standard Librray - String | |
// Keith Harrison http://useyourloaf.com | |
// Import Foundation if you want to bridge to NSString | |
import Foundation | |
// ==== | |
// Initializing a String | |
// ==== |
func downsample(imageURL: URL, to pointSize: CGSize, scale: CGFloat) -> UIImage { | |
let imgeSourceOptions = [kCGImageSourceShouldCache: false] as CFDictionary | |
let imageSource = CGImageSourceCreateWithURL(imageURL as CFURL, imgeSourceOptions)! | |
let maxDimensionInPixel = max(pointSize.width, pointSize.height) * scale | |
let downsampleOptions = [ | |
kCGImageSourceCreateThumbnailFromImageAlways: true, | |
kCGImageSourceShouldCacheImmediately: true, | |
kCGImageSourceCreateThumbnailWithTransform: true, | |
kCGImageSourceThumbnailMaxPixelSize: maxDimensionInPixel |
import Foundation | |
var todos = [String: Any]() | |
let dispatchGroup = DispatchGroup() | |
for todo in 0..10 { | |
let url = URL(string: "https://jsonplaceholder.typicode.com/todos/\(todo)") | |
dispatchGroup.enter() | |
let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in |
[ | |
{ "ProductNumber":"GP_1134", | |
"Description": "Piza", | |
"StockQuantity":"0", | |
"SalesPrice":"12", | |
"SalesPriceCur":"EUR", | |
"id":"1" | |
}, | |
{ "ProductNumber":"GPB_1134", | |
"StockQuantity":"0", |
/***** | |
* Functions statments | |
* **/ | |
function calcAge(birthyear) { | |
return 2018-birthyear; | |
} | |
var age = calcAge(1989); | |
console.log(age); |
/********************** | |
* Truthy & falsy values | |
***/ | |
// falsy values : undefined, null, 0, '', NaN | |
// truthy valyes: not falsy values | |
var height; | |
if (height || height === 0 ) { | |
console.log('value defined'); |
/******* | |
* If / else statments | |
* */ | |
var firstName = 'john'; | |
var civilStatus = 'single'; | |
if (civilStatus === 'single') { | |
console.log('single'); | |
} else { | |
console.log('married'); |
/*************************** | |
* Basic Operators | |
* | |
*/ | |
var year, yearJohn; | |
// Math operators | |
year = 2018 |