Skip to content

Instantly share code, notes, and snippets.

View dlsolution's full-sized avatar
🏠

Linh Vo dlsolution

🏠
View GitHub Profile
@dlsolution
dlsolution / dates-in-swift.md
Created January 18, 2021 07:03
dates-in-swift.md

Objects for working with Date in Swift's Foundation framework:

  • Date: This is a struct that represents a specific point in time independent of any calendar or time zone. It has methods for creating dates, comparing dates and calculating time intervals between dates. It is not responsible for the date format or conversions between string and date.

  • DateFormatter: It provides methods for converting Date to String and String to Date. You can customise the date string using predefined styles in DateFormatter.Style or create your own custom format.

  • DateComponents: This is a Date or Time object represented in units such as the year, month, day, minute or hour in a particular calendar. It provides direct access to different parts of a date or time.

Resources

@dlsolution
dlsolution / ios-interview-resources.md
Created January 18, 2021 07:05
ios-interview-resources.md
@dlsolution
dlsolution / async_swift_proposal.md
Created January 21, 2021 15:34 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async semantics proposal for Swift

Modern Cocoa development involves a lot of asynchronous programming using blocks and NSOperations. A lot of APIs are exposing blocks and they are more natural to write a lot of logic, so we'll only focus on block-based APIs.

Block-based APIs are hard to use when number of operations grows and dependencies between them become more complicated. In this paper I introduce asynchronous semantics and Promise type to Swift language (borrowing ideas from design of throw-try-catch and optionals). Functions can opt-in to become async, programmer can compose complex logic involving asynchronous operations while compiler produces necessary closures to implement that logic. This proposal does not propose new runtime model, nor "actors" or "coroutines".

Table of contents

@dlsolution
dlsolution / FastScrollingCollectionView.md
Created March 23, 2021 03:52
UICollectionView with optimized smooth scrolling and improved performance. I expect that you use this when you want to add UICollectionView displaying images to your app.

FastScrollingCollectionView

UICollectionView with optimized smooth scrolling and improved performance.

I expect that you use this when you want to add UICollectionView displaying images to your app.

Tips

1. Cache image

We can use SDWebImage. Standing on the shoulders of giants.

@dlsolution
dlsolution / PerformanceTips.md
Last active March 23, 2021 03:57
Kingfisher Performance Tips

Performance Tips

Cancelling unnecessary downloading tasks

Once a downloading task initialized, even when you set another URL to the image view, that task will continue until finishes.

imageView.kf.setImage(with: url1) { result in 
 // `result` is `.failure(.imageSettingError(.notCurrentSourceTask))`
@dlsolution
dlsolution / WWDC18-416.md
Created April 11, 2021 09:45 — forked from SheldonWangRJT/WWDC18-416.md
WWDC18 Notes by Sheldon - Session 416 - iOS Memory Deep Dive

WWDC18 Notes - Session 416 - iOS Memory Deep Dive

All session list link: Here
Session Link: Here
Demo starts @ 25:30 in the video.
Download session slides: Here

This notes is written by Sheldon after watching WWDC18 session 416. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

// https://medium.com/@samermurad555/ios-provisional-notifications-eeb3832836fc
import UserNotifications
import UIKit
typealias GrantCb = (_ didGrant: Bool) -> Void
// Manages Notifications Permissions
class NotificationManager {
static let instance = NotificationManager()