Classes, structures, and enumerations can define subscripts, which are shortcuts for accessing the member elements of a collection, list, or sequence. You use subscripts to set and retrieve values by index without needing separate methods for setting and retrieval. For example, you access elements in an
someArray[index]and elements in a
You can define multiple subscripts for a single type, and the appropriate subscript overload to use is selected based on the type of index value you pass to the subscript. Subscripts are not limited to a single dimension, and you can define subscripts with multiple input parameters to suit your custom type’s needs.
Very often in Swift, you can see various methods called one each other and linked by a dot “.”.
These methods are called chained methods. Probably using Alamofire you already have seen this behaviour:
So, what I want to share today is how to make windows with cool UI in a macOS application written in Cocoa/Swift.
This an example of what you see when create a new project from scratch in XCode and run it:
Let’s make an example to understand better the scope of this tutorial.
You want to:
- increment all numbers in array by 1
- double all numbers in array
- check if the numbers in array are even or odd
- multiply all numbers in array
- more and more…
How many functions should you create to do this?
Imagine that you need to add a file in your XCode project the first time that you build the app.
For instance, you have a configuration file, in Swift, that you want to compile and embed in your app (instead of using a PLIST file that is in CLEAR…) during the build phase and of course use in your project.
here a conversion on an old tutorial in Swift about the Levenshtein distance of two strings.
what I want to share is an ordered and readable Podfile.
The Podfile is a specification that describes the dependencies of the targets of one or more Xcode projects.
Scope of the project,
add a speedometer on my MTB to store and track the trip using only Bluetooth transmission, send data to iPhone and store to cloud for later data-analysis.
- digital display (controlled by the iOS app). Can show current speed (km/h), total km, current temperature, current humidity.
- GPS module
- bluetooth module
- DHT sensor for temperature and humidity
- Swift backend
- mongoDB as database
- Swift iOS App
I’m a full-stack developer, so I build my iOS applications in Swift and backends in Node.js… why not use Swift for both platforms (iOS and backend)?
Mac OSx Screen Saver, created using the source file of itself! 🙂