Mostrar una vista modal de izquierda a derecha

Para abrir la ventana
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];
[self presentModalViewController:viewCtrl animated:NO];

Para cerrar la ventana cambiamos la llamada:

[self presentModalViewController:viewCtrl animated:YES];

Por

CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];

[self presentModalViewController:viewCtrl animated:NO];

Poner una imagen en un control UIPickerView

Hay que utilizar este metodo en lugar del que solo devuelve el texto.

– (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
NSString *t=@»»;
UIView *tmpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 32)];
UILabel *channelLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, 250, 25)];
t=def.funciones[row];
UIImage *img = [UIImage imageNamed:@»Nombredelaimagen»];
UIImageView *temp = [[UIImageView alloc] initWithImage:img];
temp.frame = CGRectMake(0, 0, 25, 25);
[tmpView insertSubview:temp atIndex:0];
channelLabel.text = @»El texto que quieres»;
[channelLabel adjustsFontSizeToFitWidth];
channelLabel.textAlignment = UITextAlignmentLeft;
channelLabel.backgroundColor = [UIColor clearColor];
[tmpView insertSubview:channelLabel atIndex:0];

return tmpView;

}

Como detectar el dispositivo y el idioma

Para detectar el idioma:
NSString *locale = [[NSLocale currentLocale] localeIdentifier]; // en_US

Para detectar el dispositivo:
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if (altopantalla == 568)
{
//es un iphone 5

}
else
{
//es un iphone

}
} else {
//es un ipad
}

Generar certificado APNS

To generate a certificate on a Mac OS X:
Log-in to the iPhone Developer Program Portal
Choose App IDs from the menu on the right (or click here)
Create an App ID without a wildcard. For example 3L223ZX9Y3.com.armiento.test
Click the Configure link next to this App ID and then click on the button to start the wizard to generate a new Development Push SSL Certificate (Apple Documentation: Creating the SSL Certificate and Keys)
Download this certificate and double click on aps_developer_identity.cer to import it into your Keychain
Launch Keychain Assistant (located in Application, Utilities or search for it with Spotlight) and click on My Certificates on the left
Expand Apple Development Push Services and select Apple Development Push Services AND your private key (just under Apple Development Push Services)
Right-click and choose «Export 2 elements…» and save as server_certificates_bundle_sandbox.p12 (don’t type a password).
Open Terminal and change directory to location used to save server_certificates_bundle_sandbox.p12 and convert the PKCS12 certificate bundle into PEM format using this command (press enter when asked for Import Password):
openssl pkcs12 -in server_certificates_bundle_sandbox.p12 -out server_certificates_bundle_sandbox.pem -nodes -clcerts

Poner un disco SSD como primario en macbook pro

No tiene que ver con Xcode, pero hace que vaya mas rapido 🙂

Despues de desmontar el portatil quité el CD y le puse el disco SSD como disco secundario.
http://www.ifixit.com/Guide/Installing+MacBook+Pro+13-Inch+Unibody+Early+2011+Dual+Hard+Drive/8529/1

Luego se arranca y se clona el disco con el siguiente programa:
http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html
Estos son los pasos:
http://circuitremix.com/?q=content/macbook-pro-solid-state-drive-upgrade-guide-and-performance-testing

Por ultimo vuelvo a desmontar el portatil e intercambio los discos.
Arranco y desde preferencias me voy a reiniciar y selecciono como disco de arranque el SSD y a volar …..

Filtrar solo los contactos que tienen email

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

@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];
}];

ejemplo de action sheet

En el fichero .h hay que poner el delegado:
UIActionSheetDelegate

En el fichero .m

-(void)AbrirOpciones:(id)sender{
pickerViewPopup = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
UIPickerView *chPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 44.0, 0.0, 0.0)];
chPicker.dataSource = self;
chPicker.delegate = self;
chPicker.showsSelectionIndicator = YES;
[pickerViewPopup addSubview:chPicker];
[pickerViewPopup showInView:self.view];
[pickerViewPopup setBounds:CGRectMake(0,0,320, 464)];
UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerToolbar sizeToFit];
}
#pragma mark – opcion sobre el video
– (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSLog(@»Hemos elegido la opcion %d»,row);
switch (row) {
case 0:

[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
break;
case 1:

[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
break;
case 2:
[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
break;
default:
[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
break;
}

}

– (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return 3;
}

– (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
switch (row) {
case 0:
return @»texto 1″;
break;
case 1:
return @»texto 2″;
break;
case 2:
return @»texto 3″;
break;
default:
break;
}
return @»»;
}
– (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}

hilos objective-c

[NSThread detachNewThreadSelector:@selector(startTheBackgroundJob) toTarget:self withObject:nil];
Mas información en : http://www.xprogress.com/snippet-10-example-of-threading-in-iphone-sdk-objective-c-using-nsthread/

saber si un hilo es principal
[NSThread isMainThread]