This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct AssociatedKeys { | |
static var placeholderColor: String = "placeholderColor" | |
} | |
var placeholderColor: UIColor? { | |
set { | |
objc_setAssociatedObject(self, &AssociatedKeys.placeholderColor, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN) | |
} | |
get { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Instance { | |
static var floating: Bool = false | |
} | |
var floating: Bool{ | |
set{ | |
Instance.floating = newValue | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NotificationCenter.default.addObserver(self, selector: #selector(self.handleKeyboard), name: .UIKeyboardWillHide, object: nil) | |
NotificationCenter.default.addObserver(self, selector: #selector(self.handleKeyboard), name: .UIKeyboardWillShow, object: nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First just enable battery monitoring: | |
UIDevice.current.isBatteryMonitoringEnabled = true | |
Then you can create a computed property to return the battery level: | |
var batteryLevel: Float { | |
return UIDevice.current.batteryLevel | |
} | |
To monitor your device battery level you can add an observer for the UIDeviceBatteryLevelDidChange notification: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fix owner of files and folders recursively | |
sudo chown -vR $(whoami) /usr/local /opt/homebrew-cask /Library/Caches/Homebrew | |
# fix read/write permission of files and folders recursively | |
chmod -vR ug+rw /usr/local /opt/homebrew-cask /Library/Caches/Homebrew | |
# fix execute permission of folders recursively | |
find /usr/local /opt/homebrew-cask /Library/Caches/Homebrew -type d -exec chmod -v ug+x {} + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//finding memory location of stack and heap | |
func addressHeap<T: AnyObject>(o: T) -> Int { | |
return unsafeBitCast(o, to: Int.self) | |
} | |
func addressStack(o: UnsafeRawPointer) -> Int { | |
return Int(bitPattern: o) | |
} | |
//structure is a value based |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate> | |
{ | |
NSMutableArray *data; | |
} | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// Override point for customization after application launch. | |
[self.window makeKeyAndVisible]; | |
NSString *assetLocalPath = [[NSBundle mainBundle] pathForResource:@"AnimatedSplashScreen" ofType:@"gif"]; | |
NSURL *assetURL = [[NSURL alloc] initFileURLWithPath:assetLocalPath]; | |
//add the image to the forefront... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "employees": [ | |
{ | |
"createdAt": "2015-07-18T19:41:01.125Z", | |
"department": "Marketing", | |
"email": "[email protected]", | |
"name": "Louis Campbell", | |
"objectId": "1xnwPwwWVk", | |
"phone": "(517)-516-9601", | |
"skills": [ | |
"html", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)isTimeFallsBetweenTwoDates:(NSDate*)start another:(NSDate*)end{ | |
NSCalendar *gregorian = [[NSCalendar alloc] | |
initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; | |
NSDateComponents *openingTime = [gregorian components:(NSCalendarUnitHour | | |
NSCalendarUnitMinute) fromDate:start]; | |
NSDateComponents *closingTime = [gregorian components:(NSCalendarUnitHour | | |
NSCalendarUnitMinute) fromDate:end]; | |
NSDate *now = [NSDate date]; |