Advertisement
Guest User

.mfile

a guest
Jan 29th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. #import "PlayViewController.h"
  4.  
  5. @interface PlayViewController ()
  6.  
  7. @end
  8.  
  9. @implementation PlayViewController
  10.  
  11. @synthesize b1;
  12. @synthesize b2;
  13. @synthesize b3;
  14. @synthesize b4;
  15. @synthesize b5;
  16. @synthesize b6;
  17. @synthesize b7;
  18. @synthesize b8;
  19. @synthesize b9;
  20. @synthesize tv;
  21. @synthesize imageArray;
  22. @synthesize textArray,player;
  23. @synthesize image;
  24. @synthesize combinedarray;
  25. @synthesize soundArray;
  26. @synthesize dict;
  27.  
  28.  
  29. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  30. {
  31.     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  32.     if (self) {
  33.         // Custom initialization
  34.     }
  35.     return self;
  36. }
  37.  
  38. - (void)viewDidLoad
  39. {
  40.     [super viewDidLoad];
  41.     UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"learn_page.jpg"]];
  42.     [[self view] setBackgroundColor:background];
  43.  
  44.  
  45.      
  46.    
  47.     textArray =[[NSMutableArray alloc] initWithObjects:
  48.     @"circle",@"crescent",@"curvilinear_triangle",@"ellipse",
  49.     @"heptagon",@"kite",@"oval",@"paralelogram",@"pentagon",
  50.     @"rectangle",@"square",@"triangle",@"blue-jay",@"cardinal",
  51.     @"crow",@"duck",@"hawk",@"hummingbird",@"owl"@"parrot",
  52.     @"peacock",@"robin",@"sparrow",@"woodpecker",@"elephant",
  53.     @"cow",@"horse",@"kangaroo",@"lion",@"monkey",@"mouse",
  54.     @"panda",@"rabbit",@"sheep",@"zebra",nil];
  55.    
  56.     soundArray = [[NSMutableArray alloc] initWithObjects:
  57.     @"circle.mp3",@"crescent.mp3",@"curvilinear_triangle.mp3",
  58.     @"ellipse.mp3",@"heptagon.mp3",@"kite.mp3",@"oval.mp3",
  59.     @"paralelogram.mp3",@"pentagon.mp3",@"rectangle.mp3",
  60.     @"square.mp3",@"triangle.mp3",@"blue-jay.mp3",@"cardinal.mp3",
  61.     @"crow.mp3",@"duck.mp3",@"hawk.mp3",@"hummingbird.mp3",
  62.     @"owl.mp3"@"parrot.mp3",@"peacock.mp3",@"robin.mp3",
  63.     @"sparrow.mp3",@"woodpecker.mp3",@"elephant.mp3",@"cow.mp3",
  64.     @"horse.mp3",@"kangaroo.mp3",@"lion.mp3",@"monkey.mp3",
  65.     @"mouse.mp3",@"panda.mp3",@"rabbit.mp3",@"sheep",@"zebra",nil];
  66.    
  67.     NSMutableArray *imagearray = [[NSMutableArray alloc]initWithObjects:
  68.                                  
  69.     [UIImage imageNamed:@"circle.png"],
  70.     [UIImage imageNamed:@"crescent.png"],
  71.     [UIImage imageNamed:@"curvilinear_triangle.png"],
  72.     [UIImage imageNamed:@"ellipse.png"],
  73.     [UIImage imageNamed:@"heptagon.png"],
  74.     [UIImage imageNamed:@"kite.png"],
  75.     [UIImage imageNamed:@"oval.png"],
  76.     [UIImage imageNamed:@"paralelogram.png"],
  77.     [UIImage imageNamed:@"pentagon.png"],
  78.     [UIImage imageNamed:@"rectangle.png"],
  79.     [UIImage imageNamed:@"square.png"],
  80.     [UIImage imageNamed:@"triangle.png"],
  81.     [UIImage imageNamed:@"blue-jay.png"],
  82.     [UIImage imageNamed:@"cardinal.png"],
  83.     [UIImage imageNamed:@"crow.png"],
  84.     [UIImage imageNamed:@"duck.png"],
  85.     [UIImage imageNamed:@"hawk.png"],
  86.     [UIImage imageNamed:@"hummingbird.png"],
  87.     [UIImage imageNamed:@"owl.png"],
  88.     [UIImage imageNamed:@"parrot.png"],
  89.     [UIImage imageNamed:@"peacock.png"],
  90.     [UIImage imageNamed:@"robin.png"],
  91.     [UIImage imageNamed:@"sparrow.png"],
  92.     [UIImage imageNamed:@"woodpecker.png"],
  93.     [UIImage imageNamed:@"elephant.png"],
  94.     [UIImage imageNamed:@"cow.png"],
  95.     [UIImage imageNamed:@"horse.png"],
  96.     [UIImage imageNamed:@"kangaroo.png"],
  97.     [UIImage imageNamed:@"lion.png"],
  98.     [UIImage imageNamed:@"monkey.png"],
  99.     [UIImage imageNamed:@"mouse.png"],
  100.     [UIImage imageNamed:@"panda.png"],
  101.     [UIImage imageNamed:@"rabbit.png"],
  102.     [UIImage imageNamed:@"sheep.png"],
  103.     [UIImage imageNamed:@"tiger.png"],
  104.     [UIImage imageNamed:@"zebra.png"],nil];
  105.  
  106.     NSMutableArray *Dupimages = [[NSMutableArray alloc]initWithArray:image];
  107.     NSMutableArray *randomImages = [[NSMutableArray alloc]init];
  108.    
  109.    
  110.  
  111.     [b1 setBackgroundImage:[randomImages objectAtIndex:0] forState:UIControlStateNormal];
  112.     [b2 setBackgroundImage:[randomImages objectAtIndex:1] forState:UIControlStateNormal];
  113.     [b3 setBackgroundImage:[randomImages objectAtIndex:2] forState:UIControlStateNormal];
  114.     [b4 setBackgroundImage:[randomImages objectAtIndex:3] forState:UIControlStateNormal];
  115.     [b5 setBackgroundImage:[randomImages objectAtIndex:4] forState:UIControlStateNormal];
  116.     [b6 setBackgroundImage:[randomImages objectAtIndex:5] forState:UIControlStateNormal];
  117.     [b7 setBackgroundImage:[randomImages objectAtIndex:6] forState:UIControlStateNormal];
  118.     [b8 setBackgroundImage:[randomImages objectAtIndex:7] forState:UIControlStateNormal];
  119.     [b9 setBackgroundImage:[randomImages objectAtIndex:8] forState:UIControlStateNormal];
  120.      
  121.     int rendom=arc4random()%9;
  122.     [tv setText:[textArray objectAtIndex:rendom]];
  123.    
  124.     NSString *url=[NSString stringWithFormat:@"%@",tv.text];
  125.     NSLog(@"%@",url);
  126.     NSString *soundPath =[[NSBundle mainBundle] pathForResource:url ofType:@"mp3"];
  127.     NSURL *soundURL = [NSURL fileURLWithPath:soundPath];
  128.    
  129.  
  130.     NSError *error;
  131.     player=[[AVAudioPlayer alloc]initWithContentsOfURL:soundURL error:&error];
  132.     player.volume=1.0;
  133.     player.delegate=self;
  134.    
  135.     [player play];
  136. }
  137.  
  138.  
  139. -(void) randomText
  140. {
  141.    
  142. }
  143.  
  144. -(IBAction)b1:(id)sender{
  145.    
  146.     NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:0]integerValue]];
  147.     tv.text=myString;
  148.  
  149. }
  150. -(IBAction)b2:(id)sender{
  151.    
  152.     NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:1] intValue]];
  153.     tv.text=myString;
  154.    
  155. }
  156. -(IBAction)b3:(id)sender{
  157.  
  158.     NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:2] intValue]];
  159.     tv.text=myString;
  160. }
  161. -(IBAction)b4:(id)sender{
  162.  
  163.     NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:3] intValue]];
  164.     tv.text=myString;
  165. }
  166. -(IBAction)b5:(id)sender{
  167.    
  168.     NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:4] intValue]];
  169.     tv.text=myString;
  170. }
  171. -(IBAction)b6:(id)sender{
  172.    
  173.    
  174.     NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:5] intValue]];
  175.     tv.text=myString;
  176. }
  177. -(IBAction)b7:(id)sender{
  178.  
  179.    
  180.     NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:6] intValue]];
  181.     tv.text=myString;
  182. }
  183. -(IBAction)b8:(id)sender{
  184.    
  185.    
  186.     NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:7] intValue]];
  187.     tv.text=myString;
  188. }
  189. -(IBAction)b9:(id)sender{
  190.      
  191.    
  192.     NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:8] intValue]];
  193.     tv.text=myString;
  194. }
  195.  
  196. - (void)didReceiveMemoryWarning
  197. {
  198.     [super didReceiveMemoryWarning];
  199.     // Dispose of any resources that can be recreated.
  200. }
  201.  
  202. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement