Other articles

  1. "Python script to change bundle id"

    Wed 24 September 2014

    import getopt, sys

    import re

     

    def replaceStringKey(key, value, result):

        pattern = "(?P<first><key>"+key+"</key>[\\r\\n\s]*<string>)[\S]*(?P<second></string>)"

        p = re.compile(pattern)

        result = p.sub("\g<1>" + value + "\g<2>", result)

        return result

     

    def replaceIntegerKey(key, value, result):

        pattern = "(?P<first><key>"+key+"</key ...

    read more
  2. "Swift. Add text to Image"

    Sat 13 September 2014

    import UIKit

     

    func createARGBBitmapContext(inImage: CGImage) -> CGContext {

        var bitmapByteCount = 0

        var bitmapBytesPerRow = 0

        

        let pixelsWide = CGImageGetWidth(inImage)

        let pixelsHigh = CGImageGetHeight(inImage)

        

        bitmapBytesPerRow = Int(pixelsWide) * 4

        bitmapByteCount = bitmapBytesPerRow * Int(pixelsHigh)

        

        let colorSpace = CGColorSpaceCreateDeviceRGB()

        let bitmapData = malloc(CUnsignedLong(bitmapByteCount))

        let bitmapInfo = CGBitmapInfo.fromRaw(CGImageAlphaInfo.PremultipliedFirst.toRaw())!

        

        let context = CGBitmapContextCreate(bitmapData, pixelsWide, pixelsHigh ...

    read more
  3. "Get Device Model"

    Wed 09 January 2013
    + (NSString *)getDeviceModel {
        size_t size;
        char *model = malloc(size);
        sysctlbyname("hw.machine", model, &size, NULL, 0);
        NSString *sDeviceModel = [NSString stringWithCString:model encoding:NSUTF8StringEncoding];
        free(model);
        NSUInteger len = [sDeviceModel length];
        return [sDeviceModel substringToIndex:len - 2];
    }
    
    read more
  4. "Compare two NSDictionary"

    Wed 09 January 2013
    /**
    * All items form etalonDictionary should be in dictionary. Extra keys from dictionary should be ignored
    */
    -(BOOL)isEtalonDictionary:(NSDictionary *)etalonDictionary sameAs:(NSDictionary *)dictionary{
        BOOL res = NO;
        for (id item in etalonDictionary){
            NSObject *secondObject = [dictionary objectForKey:item];
            if (secondObject == nil)
                return NO;
            else{
                NSObject *value = [etalonDictionary objectForKey:item];
                if ([value isKindOfClass:[NSString ...
    read more
  5. "Methods to support orientation in iOS 6 SDK"

    Wed 31 October 2012

     

    //For UIViewController's

    - (BOOL)shouldAutorotate {

        return YES;

    }

     

    - (NSUInteger)supportedInterfaceOrientations {

        return UIInterfaceOrientationMaskAllButUpsideDown;

    }

     

    //For Delegate

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

        return UIInterfaceOrientationMaskAllButUpsideDown;

     

    read more
  6. "Get File Size"

    Thu 05 July 2012

    -(NSNumber *)getFileSize:(NSString *)fileName{

        NSError *error = nil;

        NSDictionary *attributes = [[NSFileManager defaultManager]

                attributesOfItemAtPath:fileName error:&error];

     

        if (!error) {

            NSNumber *size = [attributes objectForKey:NSFileSize];

            return size;

        } else {

            return [NSNumber numberWithFloat:-1];

        }

     

    }

    read more
  7. "Remove duplicates from NSArray"

    Tue 10 April 2012

    NSArray *arrWithDuplicates = [[NSArray alloc] initWithObjects: @"Bob", @"Bob",@"Olga", @"Olga", @"Robin", nil];

    NSArray *cleanedArray = [[NSSet setWithArray:arrWithDuplicates] allObjects];

    NSLog(@"%@", [cleanedArray description] );    


    read more
  8. "Add days to NSDate"

    Tue 10 April 2012

     

    for (int i = 1; i < 30; i++) {

        NSDate *newDate = [startDay.date dateByAddingTimeInterval:60*60*24*i];

        MDay *day = [[MDay alloc] init];

        day.date = newDate;

        [list addObject:day];

    }

     

    read more

Page 1 / 13 »