Skip to content

Instantly share code, notes, and snippets.

@MattFoley
MattFoley / gist:6285495
Created August 20, 2013 18:43
Navigation Controller memory management.
- (void)viewWillDisappear:(BOOL)animated
{
if (self.isMovingFromParentViewController) {
[self cleanForDealloc];
}
}
@MattFoley
MattFoley / gist:7376910
Created November 8, 2013 20:10
Checking for OS version or if iPad.
#define isUnderOS7() ([[[UIDevice currentDevice] systemVersion] integerValue] < 7)
#define isPad() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
@MattFoley
MattFoley / gist:cf49f4af2155aada6d52
Created July 25, 2014 15:47
Update CDM mapper to handle transformable core data attributes.
- (Class)expectedClassForObject:(NSManagedObject *)object andKey:(id)key
{
NSDictionary *attributes = [[object entity] attributesByName];
NSAttributeDescription *attributeDescription = [attributes valueForKey:key];
NSString *className = [attributeDescription attributeValueClassName];
if (!className) {
const char *className = [[object.entity managedObjectClassName] cStringUsingEncoding:NSUTF8StringEncoding];
const char *propertyName = [key cStringUsingEncoding:NSUTF8StringEncoding];
Class managedObjectClass = objc_getClass(className);
@MattFoley
MattFoley / gist:267c26b0a1892d4802ce
Created October 2, 2014 17:13
Install rabbitmq 2.7.1
cd $(brew --prefix)
git checkout b3fd8f3 /usr/local/Library/Formula/rabbitmq.rb
brew install rabbitmq
@MattFoley
MattFoley / gist:f6af9cf9d87c996fb5a5
Last active August 29, 2015 14:21
React Native Information
//Rather than defining containerRow as multiple hard coded elements:
containerRow {
backgroundcolor: #ffffff,
opacity 90%,
dropshadow: 4px color: #000000,
corner-radius: 10pt,
}
//We define those one use elements as classes, very simple building blocks:
containerCornerRadiusPrimary: {
@MattFoley
MattFoley / .md
Last active August 29, 2015 14:26
Upgrade to React Native head

Steps to upgrade to React Native head

  1. Delete your Derived Data and node_modules folders

  2. Reboot your computer dangling symlink

  3. Install io.js.

    nvm install iojs nvm alias default iojs

  4. Update brew

//RN attempts this @ ln686 of RCTConvert.m, imageWithContentsOfFile fails to load the image.
(lldb) po [UIImage imageWithContentsOfFile:@"file:///Users/tfallon/Library/Developer/CoreSimulator/Devices/E2A18017-6069-45C6-BFB2-814E62A3F6DA/data/Containers/Data/Application/3A2FBAD8-BCC9-417E-8644-FAD4551A681C/tmp/genImageFile.png"]
nil
//Image is loaded when I attempt this at a breakpoint on the same line.
(lldb) po [UIImage imageWithContentsOfFile:@"Users/tfallon/Library/Developer/CoreSimulator/Devices/E2A18017-6069-45C6-BFB2-814E62A3F6DA/data/Containers/Data/Application/3A2FBAD8-BCC9-417E-8644-FAD4551A681C/tmp/genImageFile.png"]
<UIImage: 0x7f9f9a41cef0>, {90, 90}
Error I get:
Class RCTStatusBarManager is implemented in both <App Path> and <Dynamic Framework Path>
One of the two will be used. Which one is undefined.
Did two-level namespacing just not make it's way to dynamic framework iOS, and only functions on OSX?
https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/executing_files.html
@MattFoley
MattFoley / gist:46519178115c4a30864f3796d4f87152
Created April 18, 2016 22:13
React Native Crashing Function
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
__block UIView *hitView;
[_stickyHeaderIndices enumerateIndexesWithOptions:0 usingBlock:^(NSUInteger idx, BOOL *stop) {
UIView *stickyHeader = [self contentView].reactSubviews[idx];
CGPoint convertedPoint = [stickyHeader convertPoint:point fromView:self];
hitView = [stickyHeader hitTest:convertedPoint withEvent:event];
*stop = (hitView != nil);
}];