Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2012
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.33 KB | None | 0 0
  1. - (void)viewDidLoad
  2. {
  3.     [super viewDidLoad];
  4.  
  5.     NSString *myfile = [[NSBundle mainBundle] pathForResource:@"list" ofType:@"plist"];
  6.     courses = [[NSDictionary alloc] initWithContentsOfFile:myfile];
  7.    
  8.     NSArray *sortList = [courses allKeys];
  9.  
  10.     courseKeys = [sortList sortedArrayUsingSelector:@selector(compare:)];
  11.  
  12.    }
  13.  
  14.  
  15. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  16. {
  17.     return 1;
  18. }
  19.  
  20.  
  21.  
  22.  
  23. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  24. {
  25.  
  26.      return [courses count];
  27.    
  28. }
  29.  
  30.  
  31.  
  32.  
  33. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  34. {
  35.     static NSString *CellIdentifier = @"Cell";
  36.    
  37.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  38.     if (cell == nil) {
  39.         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
  40.        
  41.     }
  42.    
  43.     // Configure the cell...
  44.    
  45.    
  46.     NSString *currentCourseName = [courseKeys objectAtIndex:[indexPath row]];
  47.     [[cell textLabel] setText:currentCourseName];
  48.    
  49.    
  50.     NSString *subtitle = [courses objectForKey:[courseKeys objectAtIndex:indexPath.row]];
  51.    
  52.     [[cell detailTextLabel] setText:subtitle];
  53.    
  54.     return cell;
  55.    
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement