Skip to content

Instantly share code, notes, and snippets.

CGRect newFrame = [view.superview convertRect:view.frame toView:nil];
[view.window addSubview:view];
view.frame = newFrame;
CGRect newFrame = [newSuperview convertRect:view.frame fromView:nil];
[newSuperview addSubview:view];
view.frame = newFrame;
- (void)floatIntoWindow {
if(self.superview == self.window) return;
CGRect newFrame = [self.superview convertRect:self.frame toView:nil];
[self.window addSubview:self];
self.transform = [self transformForCurrentInterfaceOrientation];
self.frame = newFrame;
}
- (void)unfloatIntoView:(UIView *)newSuperview {
- (NSSize)sizeWithSize:(NSSize)size {
if([self length] < 1) return NSZeroSize;
NSTextContainer *textContainer = [[[NSTextContainer alloc] initWithContainerSize:size] autorelease];
NSTextStorage *textStorage = [[[NSTextStorage alloc] initWithAttributedString:self] autorelease];
NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init] autorelease];
[layoutManager addTextContainer:textContainer];
[textStorage addLayoutManager:layoutManager];
[layoutManager setHyphenationFactor:0.0];
NSString *base64Encode(NSData *data);
NSString *base64Encode(NSData *data) {
BIO *context = BIO_new(BIO_s_mem());
BIO *command = BIO_new(BIO_f_base64());
context = BIO_push(command, context);
BIO_write(context, [data bytes], (int) [data length]);
(void) BIO_flush(context);
char *outputBuffer;
NSIndexSet *matches = [self.elements indexesOfObjectsWithOptions:NSEnumerationConcurrent
passingTest:(BOOL ^(ChiroXMLElement *element, NSUInteger index, BOOL *stop){
return (BOOL)([name compare:element.tag options:options] == NSOrderedSame);
})
];
@joshaber
joshaber / dct_weak.h
Created December 29, 2011 05:22 — forked from rowanj/dct_weak.h
ARC macros for weak references
#ifndef _DCT_WEAK_H
#define _DCT_WEAK_H
// Macros for portable support of notionally weak properties with ARC
// Forked from https://gist.github.com/1354106
// Updated by Rowan James
// Available at https://gist.github.com/1530868
// Defines:
// dct_weak to be used as a replacement for the 'weak' keyword:
// @property (dct_weak) NSObject* propertyName;
@interface MyClass : NSObject
@annotate(APIKey="object_id")
@property (nonatomic, strong) NSString *objectID;
@annotate(APIKey="full_name")
@property (nonatomic, strong) NSString *name;
@end
[[[NSUserDefaults standardUserDefaults] rac_subscribableForKeyPath:@"MyUserDefault" onObject:self] subscribeNext:^(id x) {
NSLog(@"%@", x);
}];
Thread 6 Crashed:: Dispatch queue: com.apple.root.default-priority
0 ??? 0x000000010116a390 0 + 4313228176
1 libdispatch.dylib 0x00007fff9a3634e2 _dispatch_send_wakeup_main_thread + 66
2 libdispatch.dylib 0x00007fff9a364e1c _dispatch_queue_wakeup_main + 48
3 libdispatch.dylib 0x00007fff9a364e91 _dispatch_wakeup + 72
4 libdispatch.dylib 0x00007fff9a364eef _dispatch_queue_push_list_slow + 33