Skip to content

Instantly share code, notes, and snippets.

View ASSASSINYM's full-sized avatar

Raven ASSASSINYM

View GitHub Profile
@ASSASSINYM
ASSASSINYM / PSPDFUIKitMainThreadGuard.m
Created November 8, 2022 03:03 — forked from steipete/PSPDFUIKitMainThreadGuard.m
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@ASSASSINYM
ASSASSINYM / AnyError.swift
Created June 25, 2022 03:02 — forked from nnsnodnb/AnyError.swift
How to upload jpeg image using URLSession.
import Foundation
struct AnyError: Error {
let error: Error
init(_ error: Error) {
self.error = error
}
}
@ASSASSINYM
ASSASSINYM / Animation.md
Created June 17, 2022 05:49 — forked from JeOam/Animation.md
iOS Core Animation: Advanced Techniques, Part 1: The Layer Beneath

Author: https://www.cyanhall.com/

1. The Layer Tree

Core Animation's original name is Layer Kit

Core Animation is a compositing engine; its job is to compose different pieces of visual content on the screen, and to do so as fast as possible. The content in question is divided into individual layers stored in a hierarchy known as the layer tree. This tree forms the underpinning for all of UIKit, and for everything that you see on the screen in an iOS application.

In UIView, tasks such as rendering, layout and animation are all managed by a Core Animation class called CALayer. The only major feature of UIView that isn’t handled by CALayer is user interaction.

There are four hierarchies, each performing a different role:

iOS CPU and GPU basics

#iOSBySheldon #CPU #GPU #60FPS #CADisplayLink

Apple always encourage us as iOS developers to try to maintain our apps running with a 60 frames per second rate (60 FPS) to make sure the best user experience. Most of the time, this comes for free because the hardwares are getting better and better.

But in some cases you may need to dig deeper if your app as a significant frame drops to fix it for the users, which leads to my post today - the basic of CPU and GPU in iOS. Whenever I encounter this kind of question, I always want to find the answer directly from Apple’s official document. I was able to find this article here. I mean this article is written mainly for #Metal and iOS game developers but I found all the info that we need. As always, I will try to summarize the best part of the article.

@ASSASSINYM
ASSASSINYM / introrx.md
Created June 1, 2022 08:56 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@ASSASSINYM
ASSASSINYM / uiview-extensions.swift
Created May 12, 2022 02:14 — forked from stakes/uiview-extensions.swift
UIImage from UIView extension
import UIKit
extension UIView {
func createImage() -> UIImage {
let rect: CGRect = self.frame
UIGraphicsBeginImageContext(rect.size)
let context: CGContextRef = UIGraphicsGetCurrentContext()
import UIKit
import Photos
import Contacts
import AVFoundation
enum Permission {
case cameraUsage
case contactUsage
case photoLibraryUsage