fespinoza / devnotes Goto Github PK
View Code? Open in Web Editor NEWSharing tidbits of development knowledge through GitHub issues
License: MIT License
Sharing tidbits of development knowledge through GitHub issues
License: MIT License
It basically means that reading and writing on a property will happen in an atomic way (one operation), then preventing reading outdated values when a writing is occurring and so on.
// A wrapper for values in order to make their reading/writing atomic
final class Atomic<Value> {
private let queue = DispatchQueue(label: "my.queue.name")
private var _value: Value
init(value: Value) {
self._value = value
}
var value: Value {
return queue.sync {
self._value
}
}
func mutate(_ transform: (inout Value) -> Void) {
queue.sync {
transform(&self._value)
}
}
}
Recently I read this post Software development topics I’ve changed my mind on after 6 years in the industry - Blogomatano and even though I didn’t agree with all the points in there, it did motivate me to write my own collection of opinions regarding software development in general. These are a collection of my opinions, you can agree or disagree with and that's ok.
I will probably update this list if something important comes to my mind.
You can comment bellow if you want me to elaborate more on a certain points, some of them may deserve their own post.
Integrating with Swift projects which use 'use_frameworks!' in the Podfile
ios - Why do we use use_frameworks in CocoaPods? - Stack Overflow
CocoaPods 1.5.0 — Swift Static Libraries - CocoaPods Blog
Cocoa Touch Frameworks
They are always open-source and will be built just like your app. (So Xcode will sometimes compile it, when you run your app and always after you cleaned the project.) Frameworks only support iOS 8 and newer, but you can use Swift and Objective-C in the framework.
Cocoa Touch Static Libraries
As the name says, they are static. So they are already compiled, when you import them to your project. You can share them with others without showing them your code. Note that Static Libraries currently don’t support Swift. You will have to use Objective-C within the library. The app itself can still be written in Swift.
A SwiftUI view that represents a UIKit view controller can define a Coordinator type that SwiftUI manages and provides as part of the representable view’s context.
You can use this coordinator to implement common Cocoa patterns, such as delegates, data sources, and responding to user events via target-action.
import SwiftUI
import UIKit
struct PageViewController: UIViewControllerRepresentable {
var controllers: [UIViewController]
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
func makeUIViewController(context: Context) -> UIPageViewController {
let pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal)
return pageViewController
}
func updateUIViewController(_ pageViewController: UIPageViewController, context: Context) {
pageViewController.setViewControllers([controllers[0]], direction: .forward, animated: true)
}
class Coordinator: NSObject {
var parent: PageViewController
init(_ pageViewController: PageViewController) {
self.parent = pageViewController
}
}
}
UIViewRepresentable
UIViewControllerRepresentable
NSViewRepresentable
NSViewControllerRepresentable
UIHostingController
Source: Interfacting with UIKit - Apple
For a given file A.m
we want to create a file A.swift
to replace it:
A.swift
with the right properties and intializersfoo
in A.swift
, not necessarily improving the code, but just translating it from objc to swiftfoo
in A.m
A.m
foo
to swiftfoo
in A.m
A.m
for A.swif
in the source code (and commit)A.m
and A.h
from the projectThen reviewing the changes will be way easier by commit, as only the relevant conversions are set.
*: start with the private methods that don’t depend on other methods
class MockTimer: Timer {
var block: ((Timer) -> Void)!
static var currentTimer: MockTimer!
override func fire() {
block(self)
}
override open class func scheduledTimer(
withTimeInterval interval: TimeInterval, repeats: Bool, block: @escaping (Timer) -> Void
) -> Timer {
let mockTimer = MockTimer()
mockTimer.block = block
MockTimer.currentTimer = mockTimer
return mockTimer
}
}
Sometimes some fixes are needed only for test targets
if ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil {
// Code only executes when tests are running
}
On the terminal
defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
Source: rockthebruno
Add the following code to your AppDelegate
:
NSSetUncaughtExceptionHandler { exception in
print(exception)
exception.callStackSymbols.forEach({ print($0)} )
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.