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
document.write('<link rel="stylesheet" href="https://gist-assets.github.com/assets/embed-8bf0013c72fb64f0bb1bc1872b43e39e.css">') | |
document.write('<div id=\"gist4325186\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data gist-syntax\">\n \n\n\n\n <div class=\"file-data\">\n <table cellpadding=\"0\" cellspacing=\"0\" class=\"lines highlight\">\n <tr>\n <td class=\"line-numbers\">\n <span class=\"line-number\" id=\"file-gistfile1-as-L1\" rel=\"file-gistfile1-as-L1\">1<\/span>\n <span class=\"line-number\" id=\"file-gistfile1-as-L2\" rel=\"file-gistfile1-as-L2\">2<\/span>\n <span class=\"line-number\" id=\"file-gistfile1-as-L3\" rel=\"file-gistfile1-as-L3\">3<\/span>\n <span class=\"line-number\" id=\"file-gistfile1-as-L4\" rel=\"file-gistfile1-as-L4\">4<\/span>\n <span class=\"line-number\" id=\"file-gistfile1-as-L5\" rel=\"file-gistfile1-as-L5\">5<\/span>\n <span class=\"line-n |
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
#import <Founodation/Foundation.h> | |
// comment | |
/* | |
comment | |
*/ |
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)testWildcard1 | |
{ | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF LIKE[c] 'a*e'"]; | |
NSLog(@"%@", predicate); | |
// SELF LIKE[c] "a*e" | |
NSLog(@"%d", [predicate evaluateWithObject:@"apple"]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:@"apple watch"]); | |
// 0 |
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)testWildcard3 | |
{ | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF LIKE[c] 'a*a'"]; | |
NSLog(@"%@", predicate); | |
// SELF LIKE[c] "a*a" | |
NSLog(@"%d", [predicate evaluateWithObject:@"a"]); | |
// 0 | |
NSLog(@"%d", [predicate evaluateWithObject:@"aa"]); | |
// 1 |
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)testRegularExpression | |
{ | |
// \d+ regular expression pattern | |
// \\d+ pattern with escape for string | |
// \\\\d+ pattern with re-escape for predicate format | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES '\\d+'"]; | |
NSLog(@"%@", predicate); | |
// SELF MATCHES "d+" |
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)testImageUTI | |
{ | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF UTI-CONFORMS-TO %@", (__bridge NSString *)kUTTypeImage]; | |
NSLog(@"%@", predicate); | |
// SELF UTI-CONFORMS-TO "public.image" | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypeJPEG]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypePNG]); | |
// 1 |
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)logSizeCategory | |
{ | |
NSLog(@"%@", [WKInterfaceDevice currentDevice].preferredContentSizeCategory); | |
// 38mm UICTContentSizeCategoryS | |
// 42mm UICTContentSizeCategoryL | |
} |
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
#import <WatchKit/WatchKit.h> | |
#import <Foundation/Foundation.h> | |
@interface InterfaceController : WKInterfaceController | |
@property (nonatomic) IBOutlet WKInterfaceLabel *textLabel; | |
@end |
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
#import <UIKit/UIKit.h> | |
@interface UIViewController (UIViewControllerPresentation) | |
- (IBAction)dismiss:(id)sender; | |
@end |
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
Class cls1 = [NSObject class]; | |
NSLog(@"%@", NSStringFromClass(cls1)); | |
// NSObject | |
NSObject *object = [[NSObject alloc] init]; | |
Class cls2 = object.class; | |
NSLog(@"%@", NSStringFromClass(cls2)); | |
// NSObject |