Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread Display Modes
Old Feb 3, 2013, 10:37 PM   #1
macrumors newbie
Join Date: Mar 2011
to many requests in objective-c, please help

Hi there, I'm developing that is grabbing jpegs from parse then placing them inside of a tableview. But whenever I scroll through the table view it lags. I have figured out that this lagging is because I'm sending to many requests.

What I would like to do is send one request when the app launches, download the images then place them in the UITableView. Here is the code where the problem is occurring:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
    static NSString *CellIdentifier = @"cell";
    feedCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[feedCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    // Add the user's name
    cell.userName.text = [object objectForKey:@"name"];
    // Add the amount of likes
    cell.likes.text = [ NSString stringWithFormat:@"%@", [object objectForKey:@"Likes"]];

    PFFile *thumbnail = [object objectForKey:@"imageFile"];
    PFImageView *pfimg = [[PFImageView alloc] initWithFrame:CGRectMake(30, 27, 260, 260)];
//this is where the problem is happening:

    [thumbnail getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
        if (!error) {
            UIImage *image = [UIImage imageWithData:data];
            pfimg.image = image;
            [pfimg loadInBackground];
            NSLog(@"No Error");
            NSLog(@"Error: %@",error);
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell addSubview:pfimg];
    return cell;
thank you so much!

wfs123 is offline   0 Reply With Quote
Old Feb 3, 2013, 11:23 PM   #2
macrumors 68020
PhoneyDeveloper's Avatar
Join Date: Sep 2008
Apple Sample Code LazyTableImages.
PhoneyDeveloper is offline   0 Reply With Quote
Old Feb 4, 2013, 06:20 AM   #3
macrumors Demi-God
KoolStar's Avatar
Join Date: Oct 2006
Location: Kentucky
Send a message via AIM to KoolStar Send a message via Skype™ to KoolStar
Also checkout NSOperationQueues. They allow you to limit the number of concurrent operations (Downloads).
"Innovation distinguishes between a leader and a follower." : S.J.
KoolStar is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 04:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC