1. "Download image from HTTP server (faster)"

    Mon 11 May 2009

    //This method works much faster then [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com/intl/en_ALL/images/logo.gif"]];

    //Also it works better on bad internet connections

    NSMutableURLRequest *requestWithBodyParams = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/intl/en_ALL/images/logo.gif"]];

    NSData *imageData = [NSURLConnection sendSynchronousRequest:requestWithBodyParams returningResponse:nil error ...

    read more
  2. "Do not use NSLog in Release configuration"

    Mon 11 May 2009

    //You need o put this code into *_Prefix.pch

    #ifdef DEBUG

    #define DLog(...) NSLog(__VA_ARGS__)

    #else

    #define DLog(...) /* */

    #endif

    #define ALog(...) NSLog(__VA_ARGS__)

     

    //In build options you need to add -DDEBUG to the Other C Flags for "Debug" configuration

    //Note -- this options appears only for Device *.* configuration

    //Last step -- replace ...

    read more
  3. "Add contact to AddressBook"

    Mon 11 May 2009

    //Also you need to include AddressBook.framework

    #import <AddressBook/AddressBook.h>

    #import <AddressBook/ABAddressBook.h>

    #import <AddressBook/ABPerson.h>

     

     

     

    ABAddressBookRef addressBook = ABAddressBookCreate();

    ABRecordRef person = ABPersonCreate();

     

    ABRecordSetValue(person, kABPersonFirstNameProperty, @"Alex" , nil);

    ABRecordSetValue(person, kABPersonLastNameProperty, @"Test", nil);

    ABAddressBookAddRecord(addressBook, person, nil);

    ABAddressBookSave(addressBook, nil);

     

    CFRelease(person);


    read more

« Page 13 / 13