Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UITableViewCell *)tableView:(UITableView *)mytableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSString *a = nil, *b = nil, *c = nil, *d = nil, *e = nil;
- NSUInteger idx = 0;
- for ( NSString *string in self.ArrayofFriendsID )
- {
- switch ( idx++ ) {
- case 0: a = string; break;
- case 1: b = string; break;
- case 2: c = string; break;
- case 3: d = string; break;
- case 4: e = string; break;
- }
- }
- UITableViewCell *cell = [mytableView dequeueReusableCellWithIdentifier:@"thisCell" forIndexPath:indexPath];
- // WHAT COMES IS BAD AND NOT OPTIMAL, NEED TO FIX THAT
- if(indexPath.row == 0)
- {
- NSString *id = a;
- NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", id]];
- NSData *data = [NSData dataWithContentsOfURL:url];
- UIImage *image = [UIImage imageWithData:data];
- cell.imageView.image = image;
- }
- if(indexPath.row == 1)
- {
- NSString *id = b;
- NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", id]];
- NSData *data = [NSData dataWithContentsOfURL:url];
- UIImage *image = [UIImage imageWithData:data];
- cell.imageView.image = image;
- }
- if(indexPath.row ==2)
- {
- NSString *id = c;
- NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", id]];
- NSData *data = [NSData dataWithContentsOfURL:url];
- UIImage *image = [UIImage imageWithData:data];
- cell.imageView.image = image;
- }
- if(indexPath.row == 3)
- {
- NSString *id = d;
- NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", id]];
- NSData *data = [NSData dataWithContentsOfURL:url];
- UIImage *image = [UIImage imageWithData:data];
- cell.imageView.image = image;
- }
- if(indexPath.row == 4)
- {
- NSString *id = e;
- NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", id]];
- NSData *data = [NSData dataWithContentsOfURL:url];
- UIImage *image = [UIImage imageWithData:data];
- cell.imageView.image = image;
- }
- cell.frame = CGRectMake(0,0,200,60);
- UIColor * color = [UIColor colorWithRed:230/255.0f green:237/255.0f blue:242/255.0f alpha:1.0f];
- cell.backgroundColor = color;
- cell.textLabel.text = [self.ArrayofFiveFriends objectAtIndex:indexPath.row];
- if ([[self.ArrayofFiveFriends objectAtIndex:indexPath.row] isKindOfClass:[NSString class]] &&
- [[self.ArrayofFiveFriends objectAtIndex:indexPath.row] isEqualToString:@""]) {
- cell.textLabel.text = @"";
- cell.contentView.backgroundColor = [UIColor clearColor];
- cell.accessoryType = UITableViewCellAccessoryNone;
- }
- else {
- NSDate *object = self.ArrayofFiveFriends[indexPath.row];
- cell.textLabel.text = [object description];
- cell.accessoryType = UITableViewCellAccessoryNone;
- }
- return cell;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement