1. "Get Executable File MD5 Signature"

    Thu 25 November 2010

    #include <CommonCrypto/CommonDigest.h>

     

    @implementation YourClass

     

    -(NSString*)getExecutableFileMD5Signature{

    NSBundle *bundle = [NSBundle mainBundle];

        NSDictionary *info = [bundle infoDictionary];

    NSString *execName = [info objectForKey:@"CFBundleExecutable"];

    NSData *data = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.app/%@", NSHomeDirectory(), execName, execName]];

    return [self cHash:@"md5" data:data];

    }

     

    -(NSString*)cHash:(NSString*)algo data:(NSData*)data{

    NSData *rdata;

    if ([algo isEqualToString:@"sha1 ...

    read more
  2. "Get current language"

    Mon 18 October 2010

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    NSArray *languages = [defaults objectForKey:@"AppleLanguages"];

    NSString *currentLanguage = [languages objectAtIndex:0];

     

    NSLog(@"Current Locale: %@", [[NSLocale currentLocale] localeIdentifier]);

    NSLog(@"Current language: %@", currentLanguage);


    read more
  3. "Connect to untrusted SSL servers on iPhone"

    Mon 18 October 2010

    - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *) space {

    if([[space authenticationMethod] isEqualToString:NSURLAuthenticationMethodServerTrust]) {

    // Note: this is presently only called once per server (or URL?) until

    //       you restart the app

    if(shouldAllowSelfSignedCert) {

    return YES; // Self-signed cert will be accepted

    } else {

    return NO// Self-signed cert will be rejected

    }

    }

    return NO;

    }

     

    - (BOOL)connection:(NSURLConnection ...

    read more
  4. "Animate rotation"

    Thu 07 October 2010

    //Start 180 degrees rotation

    [UIView beginAnimations:nil context:NULL];

    [UIView setAnimationDuration:0.2];

     

    refreshArrow.transform = CGAffineTransformMakeRotation(M_PI);

     

    [UIView commitAnimations];


    read more
  5. "Restrict length for UITextField"

    Wed 29 September 2010

    - (BOOL)textField:(UITextField )textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString )strin{

    //Check that response is should be maximum 5 characters

    if ([strin length] > 0) {

    return [textField.text  length] < 5;

    }

    return YES;

    }


     

    read more
  6. "Clear background for UITableView on iPad"

    Wed 29 September 2010

    //We need have this to clear background for UITableView on iPad

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){

    [itemTable setBackgroundView:nil];

    [itemTable setBackgroundView:[[[UIView alloc] init] autorelease]];

    }

    read more
  7. "Change title on Back button"

    Tue 28 September 2010

    //We need to make this in master page to change title in back button on details page

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Master" style:UIBarButtonItemStylePlain target:nil action:nil];

    self.navigationItem.backBarButtonItem = backButton;

    [backButton release];

    read more
  8. "Creating multiline cell in UITableView"

    Tue 07 September 2010

    - (UITableViewCell *)tableView:(UITableView *)tableView

    cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"BigListCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

    cell = [[[UITableViewCell alloc]

    initWithStyle:UITableViewCellStyleDefault

    reuseIdentifier:CellIdentifier] autorelease];

    CGRect labelFrame =

    CGRectMake(CGRectGetMinX(cell.frame)+50,

      CGRectGetMinY(cell.frame), CGRectGetWidth(cell.frame)-150,

      CGRectGetHeight(cell.frame));

    UILabel *label = [[UILabel alloc]

      initWithFrame:labelFrame ...

    read more
  9. "Convert NSDate to NSString"

    Tue 07 September 2010

    -(NSString *)getStringfromDate:(NSDate *)date{

    if (!dateFormatter) {

    dateFormatter = [[NSDateFormatter alloc] init];

    [dateFormatter setDateFormat:@"dd-MMM-yyyy"];

    }

    return [[dateFormatter stringFromDate:date] uppercaseString];

    }


    read more

« Page 3 / 13 »