Guest User

Untitled

a guest
Mar 16th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XBasic 2.66 KB | None | 0 0
  1. //
  2. //  ejemplo5ViewController.m
  3. //  ejemplo5
  4. //
  5. //  Created by Usuario on 18/11/11.
  6. //  Copyright 2011 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "ejemplo5ViewController.h"
  10.  
  11. @implementation ejemplo5ViewController
  12.  
  13. @synthesize correcto;
  14.  
  15.  
  16. /*
  17. // The designated initializer. Override to perform setup that is required before the view is loaded.
  18. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  19.     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  20.     if (self) {
  21.         // Custom initialization
  22.     }
  23.     return self;
  24. }
  25. */
  26.  
  27. /*
  28. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  29. - (void)loadView {
  30. }
  31. */
  32.  
  33.  
  34.  
  35. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  36. - (void)viewDidLoad {
  37.     ordinales = [[NSArray alloc] initWithObjects: @"Primero",@"Segundo",@"Tercero",@"Cuarto",@"Quinto",nil];
  38.     cardinales = [[NSArray alloc] initWithObjects: @"Cuatro",@"Uno",@"Tres",@"Dos",@"cinco",nil];
  39.    
  40.    
  41.     [super viewDidLoad];
  42. }
  43.  
  44.  
  45. -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
  46.  
  47.     return 2;
  48.    
  49. }
  50.  
  51.  
  52. -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
  53.  
  54.     if (component == 0){ return [ordinales count]; }
  55.     else {
  56.         return [cardinales count];
  57.     }
  58.  
  59. }
  60.  
  61. -(NSString *) pickerView:(UIPickerView *) pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
  62.     if (component == 0){
  63.         return [ordinales objectAtIndex:row];
  64.     }
  65.     else {
  66.         return [cardinales objectAtIndex:row];
  67.     }
  68. }
  69.  
  70.  
  71. -(void) pickerView:(UIPickerView *) pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
  72.  
  73.     int ordinal;
  74.     int cardinal;
  75.    
  76.     ordinal = [pickerView selectedRowInComponent:0];
  77.     cardinal = [pickerView selectedRowInComponent:1];
  78.    
  79.     if ( (ordinal==0 && cardinal==1) || (ordinal==1 && cardinal==3) || (ordinal==2 && cardinal==2) || (ordinal==3 && cardinal==0) || (ordinal==4 && cardinal==4) ){
  80.         correcto.text = @"Eres un crack";
  81.     }
  82.     else{
  83.         correcto.text = @"Eres un matao";
  84.     }
  85.    
  86. }
  87.  
  88.  
  89. // Override to allow orientations other than the default portrait orientation.
  90. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  91.     return YES;
  92. }
  93.  
  94.  
  95.  
  96. - (void)didReceiveMemoryWarning {
  97.     // Releases the view if it doesn't have a superview.
  98.     [super didReceiveMemoryWarning];
  99.    
  100.     // Release any cached data, images, etc that aren't in use.
  101. }
  102.  
  103. - (void)viewDidUnload {
  104.     // Release any retained subviews of the main view.
  105.     // e.g. self.myOutlet = nil;
  106. }
  107.  
  108.  
  109. - (void)dealloc {
  110.     [super dealloc];
  111. }
  112.  
  113. @end
Add Comment
Please, Sign In to add comment