Friday, January 20, 2012

Difference between a view’s bounds and frame

The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.
The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).

So, imagine a view that has a size of 100x100 (width x height) positioned at 50,50 (x,y) of its superview. The following code prints out this view's bounds and frame:
    NSLog(@"bounds.origin.x: %f", label.bounds.origin.x);
    NSLog(@"bounds.origin.y: %f", label.bounds.origin.y);
    NSLog(@"bounds.size.width: %f", label.bounds.size.width);
    NSLog(@"bounds.size.height: %f", label.bounds.size.height);

    NSLog(@"frame.origin.x: %f", label.frame.origin.x);
    NSLog(@"frame.origin.y: %f", label.frame.origin.y);
    NSLog(@"frame.size.width: %f", label.frame.size.width);
    NSLog(@"frame.size.height: %f", label.frame.size.height);
 
output: 
bounds.origin.x: 0
bounds.origin.y: 0
bounds.size.width: 100
bounds.size.height: 100

frame.origin.x: 25
frame.origin.y: 25
frame.size.width: 100
frame.size.height: 100

Monday, January 09, 2012

iOS versions and their mountain code names

  • 1.0: Alpine
  • 1.1: Little Bear
  • 2.0: Big Bear
  • 2.1: Sugarbowl
  • 2.2: Timberline
  • 3.0: Kirkwood
  • 3.1: Northstar
  • 3.2: Wildcat
  • 4.0: Apex
  • 4.1: Baker
  • 4.2: Jasper
  • 4.3: Durango
  • 5.0: Telluride
  • 5.1: Hoodoo

Tuesday, January 03, 2012

iOS: Adding Contacts Using AddressBook Framework

    ABRecordRef aRecord = ABPersonCreate();
   
    CFErrorRef  anError = NULL;
   
    ABRecordSetValue(aRecord, kABPersonFirstNameProperty,
                      CFSTR("MAHES"), &anError);
    ABRecordSetValue(aRecord, kABPersonLastNameProperty,
                     CFSTR("CHELLAIAH"), &anError);
    ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
    ABMultiValueAddValueAndLabel(multiPhone, CFSTR("9751050790"), kABPersonPhoneMobileLabel, NULL); 
    ABRecordSetValue(aRecord, kABPersonPhoneProperty, multiPhone,nil);
    CFRelease(multiPhone);
   
    if (anError != NULL) {
       
        NSLog(@"error while creating..");
    }
   
    CFStringRef firstName, lastName;
    firstName = ABRecordCopyValue(aRecord, kABPersonFirstNameProperty);
    lastName  = ABRecordCopyValue(aRecord, kABPersonLastNameProperty);
   
   
    CFErrorRef error = NULL;
    ABAddressBookRef addressBook = ABAddressBookCreate(); 
   
    BOOL isAdded = ABAddressBookAddRecord (
                                           addressBook,
                                           aRecord,
                                           &error
                                           );
   
    if(isAdded){
       
        NSLog(@"added..");
    }
    if (error != NULL) {
        NSLog(@"ABAddressBookAddRecord %@", error);
    }
    error = NULL;
   
    BOOL isSaved = ABAddressBookSave (
                                      addressBook,
                                      &error
                                      );
   
    if(isSaved){
       
        NSLog(@"saved..");
        [self handleCall];
    }
   
    if (error != NULL) {
        NSLog(@"ABAddressBookSave %@", error);
    }
   
    CFRelease(aRecord);
    CFRelease(firstName);
    CFRelease(lastName);
    CFRelease(addressBook);

Swift Operators - Basic Part 3 (Range operators in swift)

Range Operators: Closed Range operators  Half-Open Range Operators One-Sided Ranges Closed Range Operators:  a...b It defines...