Skip to content

Instantly share code, notes, and snippets.

View justin's full-sized avatar

Justin Williams justin

View GitHub Profile
@justin
justin / gist:2298071
Created April 4, 2012 05:37
ARC Helper Macros
#ifndef SG_RETAIN
#if __has_feature(objc_arc)
#define SG_RETAIN(x) x
#define SG_RELEASE(x)
#define SG_AUTORELEASE(x) x
#define SG_SUPER_DEALLOC
#else
#define __SG_WEAK
#define SG_WEAK assign
#define SG_RETAIN(x) [x retain]
@justin
justin / gist:2295555
Created April 3, 2012 21:16
Core Location Purpose Example
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
self.locationManager.distanceFilter = 1000.0; // 1 km
self.locationManager.delegate = self;
self.locationManager.purpose = NSLocalizedString(@"To show you nearby activities", @"");
@justin
justin / gist:2288837
Created April 3, 2012 02:20
Handle delete in empty UITextField
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
if ([textField.text length] == 0)
{
textField.text = DSEmptyNewLineCharacter;
}
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
@justin
justin / gist:2288828
Created April 3, 2012 02:14
textFieldShouldReturn Example
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if ([textField isEqual:self.firstField] == YES)
{
[self.secondField becomeFirstResponder];
}
else
{
[self.secondField resignFirstResponder];
}
@justin
justin / gist:2287160
Created April 2, 2012 20:59
lldb recursiveDescription
(lldb) po [self.webView recursiveDescription]
(id) $9 = 0x0682ef80 <UIWebView: 0x6b40830; frame = (0 0; 320 460); autoresize = W+H; layer = <CALayer: 0x6b408a0>>
| <_UIWebViewScrollView: 0x6e2fce0; frame = (0 0; 320 460); clipsToBounds = YES; autoresize = H; layer = <CALayer: 0x6e2ff00>; contentOffset: {0, 0}>
| | <UIImageView: 0x6a39240; frame = (0 0; 54 54); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x6a39280>>
| | <UIImageView: 0x6a391d0; frame = (0 0; 54 54); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x6a39210>>
| | <UIImageView: 0x6a39160; frame = (0 0; 54 54); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x6a391a0>>
| | <UIImageView: 0x6a38fe0; frame = (0 0; 54 54); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x6a39130>>
| | <UIImageView: 0x6a38f70; frame = (-14.
@justin
justin / gist:2287144
Created April 2, 2012 20:55
lldb description
(lldb) po [self.webView description]
(id) $7 = 0x06a343e0 <UIWebView: 0x6b40830; frame = (0 0; 320 460); autoresize = W+H; layer = <CALayer: 0x6b408a0>>
(lldb)
@justin
justin / gist:1811777
Created February 12, 2012 23:25
Elements 2.2 Changes
  • [NEW] Font sizes now sync between device classes, so iPad syncs to iPad and iPhone to iPhone and iPod touch.
  • [NEW] Added support for .fountain extension.
  • [NEW] Now saving the scroll position of each file and folder.
  • [CHANGE] Changed default file extension to .md.
  • [CHANGE] Updated to latest version of MarkdownKit.
  • [FIX] Updated to new version of Museo Sans that should render G's and C's properly in landscape mode.
  • [FIX] Adjusted file naming rules to strip all characters Dropbox does not recommend in file names.
  • [FIX] The Facebook logo is now a bit less blurry in the Publishing sources view controller.
  • [FIX] Popovers now toggle when tapped.
  • [FIX] Miscellaneous bug fixes and performance improvements.
@justin
justin / gist:1586083
Created January 10, 2012 00:56
UIAccessibilityTraits Example
- (UIAccessibilityTraits)accessibilityTraits
{
UIAccessibilityTraits traits = UIAccessibilityTraitButton | UIAccessibilityTraitAllowsDirectInteraction | UIAccessibilityTraitStaticText;
if (self.disabled == YES)
{
traits = traits | UIAccessibilityTraitNotEnabled;
}
return traits;
@justin
justin / gist:1586076
Created January 10, 2012 00:54
UIAccessibilityElement Example
NSUInteger numberOfSegments = [self numberOfSegments];
CGFloat segmentWidth = CGRectGetWidth(self.bounds) / numberOfSegments;
CGFloat segmentHeight = CGRectGetHeight(self.bounds);
UIAccessibilityElement *element = [[UIAccessibilityElement alloc] initWithAccessibilityContainer:self];
element.isAccessibilityElement = YES;
CGRect segmentFrame = CGRectMake(i * segmentWidth, 0, segmentWidth, segmentHeight);
element.accessibilityFrame = [self.window convertRect:segmentFrame fromView:self];
UIAccessibilityTraits traits = UIAccessibilityTraitAllowsDirectInteraction;
if (i == [self selectedSegmentIndex])
{
Whenever you synchronize your iPhone or iPod Touch, all the crash logs are transferred to your computer. Here are their locations:
* Mac OS X : [Home]/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
* Windows XP: C:\Documents and Settings\<USERNAME>\Application Data\Apple computer\Logs\CrashReporter/<DEVICE_NAME>
* Windows Vista: C:\Users\<USERNAME>\AppData\Roaming\Apple computer\Logs\CrashReporter/MobileDevice/<DEVICE_NAME>
The log file names start with application name and have the extension "crash".