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 main(int argc, char *argv[]) | |
{ | |
@autoreleasepool | |
{ | |
int retVal; | |
@try | |
{ | |
retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([YOUR_DELEGATE class])); | |
} | |
@catch (NSException *exception) |
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
NSURL *url = [NSURL URLWithString:@"http://rigmonkeyapp.com/wp-admin/admin-ajax.php?action=wpp_export_properties&api=343cae213812a8662431a29c5e6ddcc20154219b&format=json&limit=5"]; | |
NSURLRequest *request = [NSURLRequest requestWithURL:articleURL]; | |
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; | |
NSDictionary *result = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; | |
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
[PRouter addOption:@[@"n", @"new"] callback:^(NSString *value) { | |
NSDictionary *manifest = @{ | |
@"name" : @"", | |
@"description" : @"", | |
@"version" : @"", | |
@"author" : @"", | |
@"url" : @"", | |
@"keywords" : @[] | |
}; |
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
// Supports --foo=bar and -f bar | |
static NSDictionary *arguments() | |
{ | |
NSArray *arguments = [[NSProcessInfo processInfo] arguments]; | |
if(arguments.count < 2) | |
return nil; | |
NSMutableDictionary *argsDict = [[NSMutableDictionary alloc] init]; |
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
// A small chunk of it. | |
- (void)tapGestureAction:(UITapGestureRecognizer *)gesture | |
{ | |
CGPoint location = [gesture locationInView:self]; | |
_linkLocation = location; | |
location.y += (ARTICLE_BODY_FONT_SIZE / lineHeightFactor); | |
CFArrayRef lines = CTFrameGetLines(_frame); | |
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
- (CGFloat)getContentHeight | |
{ | |
CTFramesetterRef tmpFrameSetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)_body); | |
int textLength = [_body length]; | |
CFRange range; | |
CGFloat maxWidth = self.width; | |
CGFloat maxHeight = CGFLOAT_MAX; | |
CGSize constraint = CGSizeMake(maxWidth, maxHeight); | |
CGSize contentSize = CTFramesetterSuggestFrameSizeWithConstraints(tmpFrameSetter, CFRangeMake(0, textLength), nil, constraint, &range); |
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
- (CGSize)sizeForAttributedStringWithWidth:(CGFloat)width | |
{ | |
CTTypesetterRef typesetter = CTTypesetterCreateWithAttributedString((__bridge CFAttributedStringRef)self); | |
CFIndex offset = 0, length; | |
CGFloat y = 0; | |
do { | |
length = CTTypesetterSuggestLineBreak(typesetter, offset, width); | |
CTLineRef line = CTTypesetterCreateLine(typesetter, CFRangeMake(offset, length)); | |
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 CGRect clipRectToPath(CGRect rect, CGPathRef path) | |
{ | |
size_t width = floorf(rect.size.width); | |
size_t height = floorf(rect.size.height); | |
uint8_t *points = calloc(width * height, sizeof(*points)); | |
CGContextRef bitmapContext = CGBitmapContextCreate(points, width, height, sizeof(*points) * 8, width, NULL, kCGImageAlphaOnly); | |
BOOL atStart = NO; | |
NSRange range = NSMakeRange(0, 0); | |
NSUInteger x = 0; |
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
[WCXMLParser parseXMLString:operation.responseString withOptions:0 success:^(WCXMLParser *parser, id parsedObject) { | |
NSLog(@"PARSED: %@", parsedObject); | |
} failure:^(WCXMLParser *parser, NSError *error) { | |
NSLog(@"ERROR: %@", [error description]); | |
}]; |
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
(function(){ | |
var imagePreload = function(imageUrlList) | |
{ | |
for(var i = 0; i < imageUrlList.length; i++) | |
{ | |
var image = new Image(); | |
image.src = imageUrlList[i]; | |
} | |
} |