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 char kDHStyleKey; | |
@interface UIView (DHStyleManager) | |
@property (nonatomic, copy) NSString* styleName; | |
@end | |
@implementation UIView (DHStyleManager) | |
@dynamic styleName; | |
- (void)setStyleName:(NSString *)styleName | |
{ |
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 UIViewDHStyleManager.h" | |
UIView* v = [[[UIView alloc] init] autorelease]; | |
v.styleName = @"someStyleName"; | |
NSLog(@"v = %@",v.styleName); //Logs 'someStyleName' |
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
JavascriptContext* ctx = [[JavascriptContext alloc] init]; | |
[ctx evaluateJS:@"2+2;"]; //Results in 4 | |
[ctx evalateJS:someScriptStoredInBundle]; | |
[ctx release]; |
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)watchConfigFile:(NSString*)path; | |
{ | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
int fildes = open([path UTF8String], O_EVTONLY); | |
__block typeof(self) blockSelf = self; | |
__block dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE,fildes, | |
DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_ATTRIB | DISPATCH_VNODE_LINK | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE, | |
queue); |
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
int fildes = open("/path/to/config.plist", O_RDONLY); | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE,fildes, | |
DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_ATTRIB | DISPATCH_VNODE_LINK | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE, | |
queue); | |
dispatch_source_set_event_handler(source, ^ | |
{ | |
//Reload the config file | |
}); |
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
FileSystemWatch* watcher = [[FileSystemWatch alloc] init]; | |
[watcher watchFileAtPath:@"path/to/config.plist" target:self action:@selector(fileChanged:)]; | |
... | |
- (void)fileChanged:(FileSystemWatch*)watcher | |
{ | |
NSLog(@"File changed, time to reload"); | |
} |
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
typedef void(^DrawView_DrawBlock)(UIView* v,CGContextRef context); | |
@interface DrawView : UIView | |
@property (nonatomic,copy) DrawableView_DrawBlock drawBlock; | |
@end |