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
//parameters | |
NSMutableArray *keys = [[NSMutableArray alloc] init]; | |
for (NSString * key in parameters) | |
{ | |
[keys addObject:key]; | |
} | |
[keys sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; | |
NSMutableString * stringParams = [[NSMutableString alloc] initWithString:@""]; |
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 encryptAndReturnParameters(parameters: [String : AnyObject]) -> [String: AnyObject] { | |
var sortedKeys = parameters.sorted{$0.0 < $1.0} | |
var paramString = "" | |
for (_, value) in sortedKeys { | |
paramString.addString(str: String(describing: value)) | |
} | |
paramString.addString(str: "YOURSECRETKEY") |
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
@property int isTyping; | |
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { | |
[self startTyping]; | |
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(stopTyping) object:nil]; | |
[self performSelector:@selector(stopTyping) withObject:nil afterDelay:0.5]; | |
return YES; |
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
UIApplicationShortcutIcon * photoIcon = [UIApplicationShortcutIcon iconWithTemplateImageName: @"selfie-100.png"]; // your customize icon | |
UIApplicationShortcutItem * photoItem = [[UIApplicationShortcutItem alloc]initWithType: @"selfie" localizedTitle: @"take selfie" localizedSubtitle: nil icon: photoIcon userInfo: nil]; | |
UIApplicationShortcutItem * videoItem = [[UIApplicationShortcutItem alloc]initWithType: @"video" localizedTitle: @"take video" localizedSubtitle: nil icon: [UIApplicationShortcutIcon iconWithType: UIApplicationShortcutIconTypeCaptureVideo] userInfo: nil]; | |
[UIApplication sharedApplication].shortcutItems = @[photoItem,videoItem]; |
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*)sha256HashFor:(NSString*)input | |
{ | |
const char* str = [input UTF8String]; | |
unsigned char result[CC_SHA256_DIGEST_LENGTH]; | |
CC_SHA256(str, (CC_LONG)strlen(str), result); | |
NSMutableString *ret = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH*2]; | |
for(int i = 0; i<CC_SHA256_DIGEST_LENGTH; i++) | |
{ | |
[ret appendFormat:@"%02x",result[i]]; |
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
for (NSString* family in [UIFont familyNames]) | |
{ | |
NSLog(@"%@", family); | |
for (NSString* name in [UIFont fontNamesForFamilyName: family]) | |
{ | |
NSLog(@" %@", name); | |
} | |
} |