Monthly Archives: March 2013

Autolayout views evenly spaced

Good solution to autolayout evenly spaced components in the view.
Link: stackoverflow.com/a/14568394

Usage:

[self.view addConstraints:       [NSLayoutConstraint constraintsForEvenDistributionOfItems:@[label1, label2, label3, label4]                                          relativeToCenterOfItem:self.view                                                      vertically:YES]];

NSLayoutConstraint+EvenDistribution.h

@interface NSLayoutConstraint (EvenDistribution)    /**   * Returns constraints that will cause a set of views to be evenly distributed horizontally   * or vertically relative to the center of another item. This is used to maintain an even   * distribution of subviews even when the superview is resized.   */  + (NSArray *) constraintsForEvenDistributionOfItems:(NSArray *)views                               relativeToCenterOfItem:(id)toView                                           vertically:(BOOL)vertically;    @end

NSLayoutConstraint+EvenDistribution.m

@implementation NSLayoutConstraint (EvenDistribution)    +(NSArray *)constraintsForEvenDistributionOfItems:(NSArray *)views                             relativeToCenterOfItem:(id)toView vertically:(BOOL)vertically  {      NSMutableArray *constraints = [NSMutableArray new];      NSLayoutAttribute attr = vertically ? NSLayoutAttributeCenterY : NSLayoutAttributeCenterX;        for (NSUInteger i = 0; i < [views count]; i++) {          id view = views[i];          CGFloat multiplier = (2*i + 2) / (CGFloat)([views count] + 1);          NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:view                                                                        attribute:attr                                                                        relatedBy:NSLayoutRelationEqual                                                                           toItem:toView                                                                        attribute:attr                                                                       multiplier:multiplier                                                                         constant:0];          [constraints addObject:constraint];      }        return constraints;  }  @end  

How PCI Cards Differ From One Another and Fit Into Your Motherboard (Lifehacker)

Posted by Whitson Gordon at Lifehacker

Building a computer isn’t all that hard, but there are a few parts that can be confusing. When you start installing PCI cards—video cards, network cards, and other expansion cards—it’s hard to know which kinds of cards are compatible with your motherboard. Linus Sebastian from Techquickie fills us in. More »

Redbox Instant Launches with Netflix-Style Streaming Movies (Redbox Instant Launches with Netflix-Style Streaming Movies)

Posted by (author unknown) at Redbox Instant Launches with Netflix-Style Streaming Movies

Redbox Instant Launches with Netflix-Style Streaming Movies (Redbox Instant Launches with Netflix-Style Streaming Movies)

Posted by (author unknown) at Redbox Instant Launches with Netflix-Style Streaming Movies

Cocoa Debugging Tip [Tod Cunningham] (iDevBlogADay)

Posted by Tod Cunningham at iDevBlogADay

I’m attending my local Ann Arbor CocoaHeads meeting tomorrow, and the topic is
Objective Tips.  So I thought I would share a tip.

What do you do when you get a crash due to an uncaught exception such as:

2013-03-13 13:30:10.186 Picross[43233:1303] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[AppDelegate crash]: unrecognized selector sent to instance 0xc04de10?*** First throw call stack:

(0x355b012 0x32ffe7e 0x35e64bd 0x354abbc 0x354a94e 0×3313663 0x12f54 0x3f0153f 0x3f13014 0x3f042e8 0x3f04450 0x926b5e12 0x9269dcca)
libc++abi.dylib: terminate called throwing an exception

This can get really frustrating as you need to figure out where in your code it crashed.  Debugger to the rescue.  In the call stack, you can find the first “low” value.  This usually represents your code.  Then you just do a symbol lookup on that value.  Such as the following when using LLDB.

im loo -a 0x12f54

 This does a image lookup which gives a nice dump including the file and line number of the offending code:

Address: Picross[0x00012f54] (Picross.__TEXT.__text + 67540)
Summary: Picross`__57-[AppDelegate application:didFinishLaunchingWithOptions:]_block_invoke112 + 52 at AppDelegate.m:216

You can see from this dump that the offending code was at line 216 in the AppDelegate.m and was from a block where I was calling a selector that didn’t exist.

I also find this GDB to LLDB guide to be a handy reference of the commands available in LLDB.

I hope this short quick tip was helpful.  Please feel free to follow me on twitter at @fivelakesstudio. I would love to hear about your experiences with the debugger or any tips you might have.


AutoScrollLabel (Cocoa Controls)

Posted by Cocoa Controls at Cocoa Controls
Provides a lightweight marquee like UILabel scrolling, think iPod track title scrolling.

image of this control

ADN Activity Collection (Cocoa Controls)

Posted by Cocoa Controls at Cocoa Controls
UIActivities to share with App.net (ADN) apps from an Activity Sheet

image of this control

DCModalSegue (Cocoa Controls)

Posted by Cocoa Controls at Cocoa Controls
A custom segue which makes a pushed back modal presenting animation.

image of this control

SJADNShareController (Cocoa Controls)

Posted by Cocoa Controls at Cocoa Controls
SJADNShareController can be used to share text only (at the moment) to App.net, either as part of the sharing menu, on Mountain Lion, or alone.

It is currently able to use App.net‘s web post intent, which it opens the post box already filled in, in the user’s browser.

image of this control

MIHSliderView (Cocoa Controls)

Posted by Cocoa Controls at Cocoa Controls
MIHSliderView is a Core Animation slider view for OS X. Any subclass of NSView can be displayed as a slide and integration into your project is as easy as using any other view since it is just a single file NSView subclass.

image of this control

WP Like Button Plugin by Free WordPress Templates