This file contains 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
func getSignalStrengthiPhoneX() -> Int { | |
let application = UIApplication.shared | |
let statusBarView = application.value(forKey: "statusBar") as! UIView | |
let statusBar = statusBarView.value(forKey: "statusBar") as! UIView | |
let foregroundView = statusBar.value(forKey: "foregroundView") as! UIView | |
for subview in foregroundView.subviews { | |
if subview.subviews.count > 0 { | |
for child in subview.subviews { |
This file contains 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
- (NSString *)readableTimeWithDuration:(NSTimeInterval)timeDuration{ | |
NSUInteger roundedTime = round(timeDuration); | |
unsigned long days = roundedTime / 86400; | |
unsigned long hours = roundedTime / 3600; | |
unsigned long minutes = (roundedTime / 60) % 60; | |
NSString *dayLabel = days > 1 ? @"Days" : @"Day"; | |
NSString *hourLabel = hours > 1 ? @"Hours" : @"Hour"; |
This file contains 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)isSameDayWithDateOne:(NSDate *)dateOne dateTwo:(NSDate *)dateTwo{ | |
NSCalendar *calender = [NSCalendar currentCalendar]; | |
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit; | |
NSDateComponents *compOne = [calender components:unitFlags fromDate:dateOne]; | |
NSDateComponents *compTwo = [calender components:unitFlags fromDate:dateTwo]; | |
return ([compOne day] == [compTwo day] && [compOne month] == [compTwo month] && [compOne year] == [compTwo year]); |
This file contains 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
//Access the oppropriate entity | |
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Task" inManagedObjectContext:((AppDelegate *)[[UIApplication sharedApplication]delegate]).managedObjectContext]; | |
//Creating a child context to use in the background thread | |
NSManagedObjectContext *context = [[NSManagedObjectContext alloc]initWithConcurrencyType:NSPrivateQueueConcurrencyType]; | |
//Setting the parent context | |
context.parentContext = ((AppDelegate *)[[UIApplication sharedApplication]delegate]).managedObjectContext; | |
//Call fetching in background |
This file contains 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
if (![[NSUSerDefaults standardUserDefaults] boolForKey:@"1.1 First Launch"]){ | |
[[NSUserDefaults standardUserDefaults]setBool:TRUE forKey:@"1.1 First Launch"]; | |
[[NSUserDefaults standardUserDefaults]synchronize]; | |
//Fist launch code to execute. | |
} |
This file contains 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
//set | |
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"clientToBroadcastTo"]) | |
[[NSUserDefaults standardUserDefaults] setObject:@"Messages" forKey:@"clientToBroadcastTo"]; | |
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"autoCheckForUpdates"]) | |
[[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:@"autoCheckForUpdates"]; | |
[[NSUserDefaults standardUserDefaults] synchronize]; | |
//edit |
This file contains 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
- (void)playPause:(id)sender { | |
player = [MPMusicPlayerController applicationMusicPlayer]; | |
if ([songs count] > 0) { | |
if (isPlaying) { | |
NSLog(@"Playing music"); | |
[player pause]; |