jueves, 6 de diciembre de 2012

poner un fondo transparente a un UITableView


UIView *backView = [[UIView alloc] initWithFrame:CGRectZero];
    backView.backgroundColor = [UIColor clearColor];
    [tableviewquequeremosponerfondo setBackgroundView:backView];

la opcion de

[tableviewquequeremosponerfondo setBackgroundColor:[UIcolor clearColor]]

NO FUNCIONA


sábado, 1 de diciembre de 2012

Filtrar solo los contactos que tienen email

utilizo una clase auxiliar para guardar los datos y poder ordenarlos.
Contacto.h
#import <Foundation/Foundation.h>

@interface Contacto : NSObject{
    NSNumber *numero;
    NSString *email;
    NSString *nombre;
}

@property (nonatomic, strong) NSNumber *numero;
@property (nonatomic, strong) NSString *email;
@property (nonatomic, strong) NSString *nombre;

@end





el codigo es:
 addressBook = ABAddressBookCreate();
   
    self.people = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
    self.filteredPeople = [NSMutableArray array];
   
    for (id record in people)
    {
        ABRecordRef person = (__bridge ABRecordRef)record;
        NSString *firstName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
        NSString *lastName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
       
        NSString *email;
        ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
        if (ABMultiValueGetCount(emails)>0){
            email = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(emails, 0);
            if (![email isEqualToString:@""]){
                // Match by name or organization
                ABRecordID abRecordID = ABRecordGetRecordID(person);
               
                // Add the matching abRecordID to filteredPeople
                Contacto *c = [[Contacto alloc]init];
                c.numero=[NSNumber numberWithInt:abRecordID];
                c.email=email;
                c.nombre=[NSString stringWithFormat:@"%@ %@",[firstName capitalizedString],[lastName capitalizedString]];
                [filteredPeople addObject:c];
            }
          
        }
       
    }
    //NSArray *sortedArray;
    filteredPeople = [filteredPeople sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
        NSString *first = [(Contacto*)a nombre];
        NSString *second = [(Contacto*)b nombre];
        return [first compare:second];
    }];