1. "Show file included into project in UIWebView"

    Mon 22 February 2010

    NSString *path = [NSString stringWithString:[[NSBundle mainBundle] pathForResource:@"feedback" ofType:@"html"]];

    webView.opaque = NO;

    webView.backgroundColor = [UIColor clearColor];

    [webView setDelegate:self];

    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path isDirectory:NO]]];


    read more
  2. "Get MD5 hash from NSData"

    Thu 18 February 2010

    #import "NSData+md5.h"

    #import <CommonCrypto/CommonDigest.h>

     

     

    @implementation NSData (Md5)

     

    -(NSString)md5{

    const char cStr = [self bytes];

    unsigned char digest[CC_MD5_DIGEST_LENGTH];

    CC_MD5( cStr, [self length], digest );

    NSString* s = [NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",

      digest[0], digest ...

    read more
  3. "Get Coordinates from Address"

    Mon 15 February 2010

     

    -(CLLocationCoordinate2D) addressLocation:(NSString *)input {

        NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv"

      [input stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

        NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];

        NSArray *listItems = [locationString componentsSeparatedByString:@","];

        double latitude = 0.0;

        double longitude = 0.0;

        if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]) {

            latitude = [[listItems ...

    read more
  4. "Connect to Evernote"

    Sun 14 February 2010

    #import "THTTPClient.h"

    #import "TBinaryProtocol.h"

    #import "UserStore.h"

    #import "NoteStore.h"

     

     

    - (void)Test

    {

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    // Keep this key private

    NSString *consumerKey = [[[NSString alloc]

      initWithString: @"YOUR_CONSUMER_KEY_HERE" ] autorelease];

    NSString *consumerSecret = [[[NSString alloc]

    initWithString: @"YOUR_CONSUMER_SECRET_HERE"] autorelease];

    // For testing we use the sandbox server.

    NSURL *userStoreUri = [[[NSURL alloc]

    initWithString: @"https ...

    read more
  5. "Check if NSDate is today"

    Sat 13 February 2010

    NSDate today = [NSDate date];

    NSCalendar gregorian = [[NSCalendar alloc]

     initWithCalendarIdentifier:NSGregorianCalendar];

     

    NSDateComponents *weekdayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit |NSYearCalendarUnitfromDate:today];

    NSInteger todayDay = [weekdayComponents day];

    NSInteger todayMonth = [weekdayComponents month];

    NSInteger todayYear = [weekdayComponents year];

     

    BOOL res = NO;

     

    //check if datedump is today

    weekdayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit)fromDate:dateDump];

    NSInteger cday = [weekdayComponents ...

    read more
  6. "Show alert (UIAlertView) on iPhone"

    Mon 08 February 2010

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

    if (buttonIndex == 1) {

    //OK clicked

    } else {

    }

    }

     

    - (void) _showAlert:(NSString*)title

    {

    UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:@"Check your networking configuration." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

    [alertView show];

    [alertView release];

    }

    read more
  7. "Scroll UITableView to the top"

    Fri 04 December 2009

    //Move to the top of UITableView

    NSIndexPath *i = [NSIndexPath indexPathForRow:0 inSection:0];

    [namesTableView scrollToRowAtIndexPath:i atScrollPosition:UITableViewScrollPositionNone animated:YES];


    read more

« Page 5 / 13 »