Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  4. rowNo = indexPath.row;
  5. PFUser *currentUser = [PFUser currentUser];
  6. PFQuery *query = [PFQuery queryWithClassName:@"Photo"];
  7. [query whereKey:@"username" equalTo:currentUser.username];
  8. [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
  9. _photo = [objects objectAtIndex:rowNo];
  10. }];
  11.  
  12. [self performSegueWithIdentifier:@"showImageCloseup" sender:self];
  13.  
  14. }
  15.  
  16. -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
  17. ImageCloseupViewController *destination = [segue destinationViewController];
  18. destination.photoObject = _photo;
  19. }
  20.  
  21. - (void)viewDidLoad
  22. {
  23. [super viewDidLoad];
  24. PFFile *p = [_photoObject objectForKey:@"photo"];
  25. [p getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
  26. if(!error){
  27. UIImage *image = [UIImage imageWithData:data];
  28. [_imageView setImage:image];
  29. }
  30. }];
  31.  
  32. [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
  33. _photo = [objects objectAtIndex:rowNo];
  34. }];
  35.  
  36. [self performSegueWithIdentifier:@"showImageCloseup" sender:self];
  37.  
  38. [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
  39. _photo = [objects objectAtIndex:rowNo];
  40. [self performSegueWithIdentifier:@"showImageCloseup" sender:self];
  41. }];
  42.  
  43. // Runs 1st - executes in background thread stores block, then runs block once it's done
  44. [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
  45. // Runs 3rd - already segued at this point
  46. _photo = [objects objectAtIndex:rowNo];
  47. }];
  48.  
  49. // Runs 2nd - starts segue
  50. [self performSegueWithIdentifier:@"showImageCloseup" sender:self];
  51.  
  52. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  53. {
  54. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  55. rowNo = indexPath.row;
  56. _photo = yourDataArray[indexPath.row];
  57. [self performSegueWithIdentifier:@"showImageCloseup" sender:self];
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement