Skip to content

Instantly share code, notes, and snippets.

// MyViewController inherts from UIViewController
@interface MyViewController()
// ---------QUESTIONS---------
// 1. Should you do this, only to avoid casting later when you need to access MyCustomView specific properties?
// 2. How does the compiler treat this property (and the backing ivar) that's re-declared at the inheriting class level?
// Does it shadow the version that exists at the UIViewController level?
// 3. Wouldn't this cause a leak?
@property (nonatomic, strong) MyCustomView *view;
@shineycode
shineycode / gist:4615575
Last active December 11, 2015 14:39
Intermittent NSLocalizedString issues
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSLog(@"Strings file: %@", [bundle pathForResource:@"Localizable" ofType:@".strings"]);
NSLog(@"Localizations: %@", [bundle localizations]);
NSLog(@"Local Dict: %@", [bundle localizedInfoDictionary]);
NSLog(@"localizedStringForKey: %@", [bundle localizedStringForKey:@"error.message.title"value:@"Wha Happened?" table:nil]);
NSLog(@"Localized String: %@", NSLocalizedString(@"error.message.title", @"Are you sure you want to start a new game?"));
// Rest of didFinishLaunchingWithOptions
@shineycode
shineycode / gist:4568567
Created January 18, 2013 21:12
ways to concatenate strings
// Different ways to concatenate strings
//
// Method 1: Using stringByAppendingString
//
NSString *string1 = @"First Text ";
NSString *string2 = @"Joined With Second";
NSString *stringAppendResult = [string1 stringByAppendingString:string2];