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
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *documentsDirectory = [paths objectAtIndex:0]; | |
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.log",stringFromDate]]; |
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
#import "GCDWebServer.h" | |
#import "GCDWebServerDataResponse.h" | |
.......... | |
@interface AppDelegate (){ | |
GCDWebServer* _webServer; | |
} | |
- (void)startWebServer{ | |
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init]; |
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
NSDate to NSString: | |
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init]; | |
[dateFormatter setDateFormat:@"yyyy-MM-dd"]; | |
NSDate* myDate = [NSDate date]; | |
NSString *stringFromDate = [dateFormatter stringFromDate:myDate]; | |
NSString to NSDate: | |
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; |
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
- (instancetype)init { | |
self = [super init]; | |
if (self) { | |
// perform initialization | |
} | |
return self; | |
} |
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
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
dispatch_async(queue, ^{ | |
// Perform long running process | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
// Update the UI | |
}); | |
});" |
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
dispatch_queue_t serialQueue = dispatch_queue_create(""imagesQueue"", DISPATCH_QUEUE_SERIAL); | |
dispatch_async(serialQueue, ^{ | |
// Perform long running process | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
// Update the UI | |
}); | |
});" |
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
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | |
// Your code here | |
#pragma clang diagnostic pop |
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
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// Your code here | |
}); |
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
var appDelegate = UIApplication.sharedApplication().delegate as AppDelegate |
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
- (NSURL *)applicationDocumentsDirectory { | |
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; | |
} |