Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ejemplo5ViewController.m
- // ejemplo5
- //
- // Created by Usuario on 18/11/11.
- // Copyright 2011 __MyCompanyName__. All rights reserved.
- //
- #import "ejemplo5ViewController.h"
- @implementation ejemplo5ViewController
- @synthesize correcto;
- /*
- // The designated initializer. Override to perform setup that is required before the view is loaded.
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- */
- /*
- // Implement loadView to create a view hierarchy programmatically, without using a nib.
- - (void)loadView {
- }
- */
- // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- - (void)viewDidLoad {
- ordinales = [[NSArray alloc] initWithObjects: @"Primero",@"Segundo",@"Tercero",@"Cuarto",@"Quinto",nil];
- cardinales = [[NSArray alloc] initWithObjects: @"Cuatro",@"Uno",@"Tres",@"Dos",@"cinco",nil];
- [super viewDidLoad];
- }
- -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
- return 2;
- }
- -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
- if (component == 0){ return [ordinales count]; }
- else {
- return [cardinales count];
- }
- }
- -(NSString *) pickerView:(UIPickerView *) pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
- if (component == 0){
- return [ordinales objectAtIndex:row];
- }
- else {
- return [cardinales objectAtIndex:row];
- }
- }
- -(void) pickerView:(UIPickerView *) pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
- int ordinal;
- int cardinal;
- ordinal = [pickerView selectedRowInComponent:0];
- cardinal = [pickerView selectedRowInComponent:1];
- if ( (ordinal==0 && cardinal==1) || (ordinal==1 && cardinal==3) || (ordinal==2 && cardinal==2) || (ordinal==3 && cardinal==0) || (ordinal==4 && cardinal==4) ){
- correcto.text = @"Eres un crack";
- }
- else{
- correcto.text = @"Eres un matao";
- }
- }
- // Override to allow orientations other than the default portrait orientation.
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- return YES;
- }
- - (void)didReceiveMemoryWarning {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
- // Release any cached data, images, etc that aren't in use.
- }
- - (void)viewDidUnload {
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
- }
- - (void)dealloc {
- [super dealloc];
- }
- @end
Add Comment
Please, Sign In to add comment