Skip to content

Instantly share code, notes, and snippets.

View embassem's full-sized avatar

Bassem Tourky embassem

View GitHub Profile
@embassem
embassem / gist:8eb816ee5831a23d6ab40bc75ed98cf8
Created November 26, 2016 07:48 — forked from snikch/gist:3661188
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@embassem
embassem / pods swift 3
Created December 4, 2016 14:33
fix pods error with swift 3
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
@embassem
embassem / Register Notification Objc-C
Created February 2, 2017 13:20
Register for remote Notification with Firebase Notification Obj-c
-(void)registerForRemoteNotification{
// Register for remote notifications. This shows a permission dialog on first run, to
// show the dialog at a more appropriate time move this registration accordingly.
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
// iOS 7.1 or earlier. Disable the deprecation warnings.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIRemoteNotificationType allNotificationTypes =
(UIRemoteNotificationTypeSound |
@embassem
embassem / Register Notification Swift
Created February 2, 2017 13:24
Register Notification Swift with Firebase
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let gcmMessageIDKey = "gcm.message_id"
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.registerForRemotrNotification();
for family: String in UIFont.familyNames()
{
print("\(family)")
for names: String in UIFont.fontNamesForFamilyName(family)
{
print("== \(names)")
}
}
@embassem
embassem / delay
Created March 14, 2017 11:44
delay swift
//*****************************************************************
// MARK: - Helper Functions
//*****************************************************************
public func delay(_ delay:Double, closure:@escaping ()->()) {
DispatchQueue.main.asyncAfter(
deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure)
}
@embassem
embassem / UIView+NibInstantiatable.swift
Created May 7, 2017 21:12 — forked from sgr-ksmt/UIView+NibInstantiatable.swift
Load ViewController from Storyboard or View from Xib (These are same name.) Require : Swift 2.0
protocol NibInstantiatable {
static var NibName: String { get }
}
extension NibInstantiatable {
static var NibName: String { return String(Self) }
static func instantiate() -> Self {
return instantiateWithName(NibName)
@embassem
embassem / modal-view.md
Created June 12, 2017 13:45 — forked from barbietunnie/modal-view.md
Swift Modal View Controller with transparent background

You can do it like this:

In your main view controller:

func showModal() {
    let modalViewController = ModalViewController()
    modalViewController.modalPresentationStyle = .OverCurrentContext
    presentViewController(modalViewController, animated: true, completion: nil)
}
@embassem
embassem / Xcode Defaults.md
Created February 11, 2018 01:50 — forked from durul/Xcode Defaults.md
Xcode Defaults

Xcode Defaults

Command Line

# Enable internal menu
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool YES

# Enable project build time
@embassem
embassem / Ignore Pods Warning in Xcode
Created February 13, 2018 13:12
Ignore Pods Warning in Xcode
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = 'YES'
end
end
end