Tuesday, August 6, 2013

Suppress warnings



#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// ...
#pragma clang diagnostic pop




#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0
        alignment = UITextAlignmentLeft;
#else
        alignment = NSTextAlignmentLeft;
#endif

Tuesday, July 30, 2013

Overriding abstract methods

[NSException raise:NSInternalInconsistencyException 
            format:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)];
If your method returns a value, it's a bit easier to use
@throw [NSException exceptionWithName:NSInternalInconsistencyException
                               reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]
                             userInfo:nil];
Thanks to Barry Wark

Sunday, April 21, 2013

Using dot notation with NSDictonary

NSDictionary+DotPath provides support for accessing and mutating nested dictionary values using dot notation. 

Given NSDictionary* dict:

dict = {
    int = 0;
    dictLevel1 =     {
        int = 1;
        dictLevel2 =         {
            int = 2;
        };
    };
}


Values can be accessed using a dot notation for the path e.g.
int i = [dict intForPath:@"dictLevel1.dictLevel2.int"]; // i = 2
Values can also be set using a dot notation for the path e.g.
[dict setInt:3 forPath:@"dictLevel1.dictLevel2.newInt"];
Which yields:
dict = {
    int = 0;
    dictLevel1 =     {
        int = 1;
        dictLevel2 =         {
            int = 2;
            newInt = 3;
        };
    };
}
If a nested dictionary doesn't exist or isn't mutable the dictionary is updated. In this example setting an array (myArray) to and undefined dictionary (dictLevel3) creates the dictionary:
NSArray* myArray = @[@"1", @"2"];
[dict setObject:myArray forPath:@"dictLevel1.dictLevel2.dictLevel3.a"];
Which yields:
dict = {
    int = 0;
    dictLevel1 =     {
        int = 1;
        dictLevel2 =         {
            int = 2;
            dictLevel3 =             {
                a = [ 1, 2 ];
            };
            newInt = 3;
        };
    };
}

Sunday, February 24, 2013

Adding UIViews to storyboards

A little gem of a post about adding views to a storyboard.

Tuesday, January 15, 2013

iOS Freemium Conversion Rate

The Rebus Show Free is a free iOS app that exists along side The Rebus Show which sells for $1.99. In the last 90 days, the free app's conversion rate of people purchasing the $1.99 upgrade is 7.3%. In the same period, the paid app earned about 20% more than the free app.

Sunday, January 13, 2013

Convert Storyboard from iPhone to iPad

This posting saved me a lot of time when creating an iPhone app from an existing iPad app. The comments contain useful info too.