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
extension Array where Element: Comparable { | |
mutating func mergeSort(_ begin: Index, _ end: Index) { | |
var tmp: [Element] = [] | |
tmp.reserveCapacity(count) | |
//local function | |
func merge(_ begin: Index, _ mid: Index, _ end: Index) { | |
tmp.removeAll(keepingCapacity: true) | |
var i = begin |
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)saveImageToPhotos:(UIImage *)image { | |
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:),nil); | |
} | |
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { | |
if (error == nil) { | |
NSLog(@"保存成功"); | |
} else { | |
NSLog(@"失败"); | |
} |
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
# buble sort | |
def bubleSort(arrList): | |
for passnum in range(len(arrList)-1, 0, -1): | |
for i in range(passnum): | |
if arrList[i] > arrList[i+1]: | |
temp = arrList[i] | |
arrList[i] = arrList[i+1] | |
arrList[i+1] = temp | |
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
//回调 | |
static void displayStatusChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { | |
// "com.apple.springboard.lockcomplete" 通知总是接在 "com.apple.springboard.lockstate" 通知后面 | |
CFStringRef nameCFString = (CFStringRef)name; | |
NSString *lockState = (__bridge NSString*)nameCFString; | |
NSLog(@"Darwin notification NAME = %@",name); | |
if([lockState isEqualToString:@"com.apple.springboard.lockcomplete"]) { | |
NSLog(@"锁屏"); | |
} else { |