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 inline CGSize screenSize() | |
| { | |
| CGSize screenSize = [UIScreen mainScreen].bounds.size; | |
| if ((NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) && UIInterfaceOrientationIsLandscape(getOrientation())) { | |
| return CGSizeMake(screenSize.height, screenSize.width); | |
| } else { | |
| return screenSize; | |
| } | |
| } |
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 <CommonCrypto/CommonDigest.h> | |
| @implementation NSObject (Utility) | |
| - (NSString*)uniqueID | |
| { | |
| // nsobject --> nsdata -- > md5 hash --> hex string (30 chars) | |
| NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self]; | |
| unsigned char result[CC_MD5_DIGEST_LENGTH]; | |
| CC_MD5([data bytes], (uint32_t)[data length], result); |
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
| // Convert property names in a text string with their value | |
| object = user defined object | |
| // your text below with the property names enclosed in square brackets | |
| NSString *result = @"Your text here with macros eg. [name], [value], [description]"; | |
| NSRegularExpression *regEx = [NSRegularExpression regularExpressionWithPattern:@"\\[(.*?)\\]" options:0 error:NULL]; | |
| NSArray *matches = [regEx matchesInString:result options:0 range:NSMakeRange(0, [text length])]; | |
| if (matches) { | |
| for (NSTextCheckingResult *match in matches) { | |
| NSString *macro = [[[text substringWithRange:match.range] stringByReplacingOccurrencesOfString:@"[" withString:@""] stringByReplacingOccurrencesOfString:@"]" withString:@""]; |
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
| // Detect the type of iPhone Device independent from iOS version | |
| CGSize size = [UIScreen mainScreen].bounds.size; | |
| CGFloat r = size.width > size.height ? size.width / size.height : size.height / size.width; | |
| if (r < 1.5) { | |
| // iPad | |
| } else if (r == 1.5) { | |
| // iPhone 4 | |
| } else if (r > 1.5) { | |
| // iPhone 5/6/6+ | |
| } |
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 MYPlayer : AVPlayer | |
| { | |
| id playerObserver; | |
| } | |
| - (void)play; | |
| - (void)stop; | |
| - (void)pause; | |
| @end |
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
| - (void)validVideoURL:(NSString*)url valid:(void(^)())valid invalid:(void(^)())invalid | |
| { | |
| // AFNetworking https://github.com/AFNetworking | |
| AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
| manager.responseSerializer = [AFHTTPResponseSerializer serializer]; | |
| manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/vnd.apple.mpegurl", @"video/mp2t", | |
| @"video/mov", @"video/mpv", @"video/3gp", @"video/mp4", nil]; | |
| NSMutableURLRequest *request = [manager.requestSerializer requestWithMethod:@"HEAD" URLString:url parameters:nil error:nil]; | |
| AFHTTPRequestOperation *operation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
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
| // | |
| // https://github.com/priore/SOAPEngine/blob/master/CSHARP/3DESClass.cs | |
| // | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Web; | |
| using System.Security.Cryptography; | |
| using System.IO; | |
| using System.Text; |
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
| // | |
| // https://github.com/priore/SOAPEngine/blob/master/CSHARP/AES256Class.cs | |
| // | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Web; | |
| using System.Security.Cryptography; | |
| using System.IO; | |
| using System.Text; |
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
| #include <stdio.h> | |
| #include <netinet/in.h> | |
| #include <stdlib.h> | |
| #include <sys/sysctl.h> | |
| #include <net/if.h> | |
| #include <string.h> | |
| #include <net/route.h> | |
| #include <arpa/inet.h> | |
| #define CTL_NET 4 /* network, see socket.h */ |
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
| - (void)setConstraintValue:(CGFloat)value forAttribute:(NSLayoutAttribute)attribute animation:(BOOL)animation | |
| { | |
| NSArray *constraints = self.view.constraints; | |
| NSPredicate *predicate = [NSPredicate predicateWithFormat:@"firstAttribute = %d", attribute]; | |
| NSArray *filteredArray = [constraints filteredArrayUsingPredicate:predicate]; | |
| NSLayoutConstraint *constraint = [filteredArray firstObject]; | |
| if (constraint.constant != value) { | |
| [self.view removeConstraint:constraint]; | |
| constraint.constant = value; | |
| [self.view addConstraint:constraint]; |