Skip to content

Instantly share code, notes, and snippets.

View fahied's full-sized avatar

Muhammad Fahied fahied

  • Emirates Airlines
  • Dubai
View GitHub Profile
@fahied
fahied / findsymbol.command
Created March 20, 2020 18:55
find Symbols/API usage in a framework
cd mapp.app //in Product folder under Xcode
nm myapp | grep UIWeb
for framework in Frameworks/*.framework; do
fname=$(basename $framework .framework)
echo $fname
nm $framework/$fname | grep UIWeb
done
@fahied
fahied / accessibilityTableCell
Last active March 13, 2020 03:23
Set Accessibility to custom UITableViewCell
In Voice-Over , in order to make an element accessible :-
1. you have to set setIsAccessibilityElement property as true which i don't find in your code.
2; The other important point is that to make child elements (subviews) to be accessible , you have to seperately make them accessible while the parent should not be accessible(you have to specify this also).
Implement the UIAccessibilityContainer Protocol in your custom - cell.
NSString *title = titleofcell;
cell.accessibilityValue = title;
cell.accessibilityLabel = [NSString stringWithFormat:@"item %ld", (long)indexPath.row];
cell.accessibilityTraits = UIAccessibilityTraitButton;
@fahied
fahied / UserDefault.swift
Created February 16, 2020 11:20
Reduce Boiler Plate code for UserDefault using PropertyWrapper
// Strongly Typed key
struct Key: RawRepresentable {
let rawValue: String
}
extension Key: ExpressibleByStringLiteral {
init(stringLiteral: String) {
rawValue = stringLiteral
}
@fahied
fahied / autotrack.swift
Last active December 17, 2019 10:16
Auto Track Analytics iOS
@objc class AutoTrackedViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
tracker.trackScreen(name: Self.screenName, className: Self.className)
addTrackingTarget()
}
override func viewDidLoad() {
@fahied
fahied / symbolicateiOS.md
Last active December 15, 2019 11:20
Symbolicate iOS crash manually

Step 1: Use the following command in Terminal to find the dSYM on your Mac which build the app

mdfind "com_apple_xcode_dsym_uuids == 12345678-90AB-CDEF-1234-567890ABCDEF"

The string "12345678-90AB-CDEF-1234-567890ABCDEF" is the UUID string from the crash report reformatted to uppercase and 8-4-4-4-12 groups.

Step 2: Symobolicate Crash Report. Excute the following line before symbolicating

iOS Swift - Cancellable Task with GCD

#iOSBySheldon

I think most of you guys know GCD pretty well. Basically, GCD is a high level API to handle multi-threading operations. We use GCD almost on daily basis to switch thread and execute codes like:

DispatchQueue.main.async { //execute some codes here } 
//switch to main queue and execute codes asynchronously

DispatchQueue.main.sync { //execute some codes here } 
//switch to main queue and execute codes synchronously
@fahied
fahied / alert.swift
Created April 10, 2019 15:27
UIWindow Alert
func showAlert(message: String) {
let alert = UIAlertController(title: "Link", message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
@fahied
fahied / MultiLineButton.swift
Created April 9, 2019 14:06
Multi Line UIButton
import UIKit
class MultiLineButton: UIButton {
// MARK: - Init
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.commonInit()
@fahied
fahied / youtubeLandscape
Created July 12, 2017 09:27
iOS: Play youtube video in fullscreen when device orientation is landscape
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if window == self.window {
return .portrait
} else {
return .allButUpsideDown
}
}
@fahied
fahied / hackerRank.swift
Last active July 4, 2017 06:14
HackerRank Read Input with Swift
//Read String array separated by new line character
func readInput () -> [String]{
let n: Int = Int(readLine()!)!
var strs = [String]()
(0...n-1).map { _ in
strs.append(readLine()!.lowercased())
}
return strs
}