Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4258400
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:38:39+00:00 2026-05-21T05:38:39+00:00

I have a UITableView that gets populated my a NSMutableArray. This is how I

  • 0

I have a UITableView that gets populated my a NSMutableArray. This is how I have it set up in my .h

@interface processViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
    NSMutableArray *processList;
}

@property (copy, readwrite) NSMutableArray *processList;

and my .m

@synthesize processList;

-(void)viewDidLoad {
    processList = [[NSMutableArray alloc] init];
}

I put a NSLog on it on the viewDidLoad, and it displays just fine. But after I run a action, the processList array returns null. Any ideas why?

Thanks
Coulton

EDIT 1:

- (void)startUploads {

// Start UIActivity in the top
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

// Start Pool
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 

// Display results for testing purposes (commented out)
NSArray *resultstwo = [database executeQuery:@"SELECT * FROM processes"];
for (NSDictionary *rowtwo in resultstwo) {

    // Get ID
    int getUserIDcount = 0;
    NSArray *getUserIDInfo = [database executeQuery:@"SELECT * FROM login"];
    for (NSDictionary *getUserIDRow in getUserIDInfo) {
        getUserIDcount++;
        NSString *oneUserID = [getUserIDRow valueForKey:@"id"];
        theUserID = [NSString stringWithFormat:@"%@", oneUserID];
    }

    // If theUserID exists...
    if (getUserIDcount == 0) {
        //myTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector: @selector(checkLogin) userInfo: nil repeats: NO];
    } else {


        // Get URL of image
        NSString *sqlImageUploadPathOne = @"./../Documents/";
        NSString *sqlImageUploadPathTwo = [rowtwo valueForKey:@"image"];
        NSString *getAlbumID = [rowtwo valueForKey:@"album"];
        NSString *sqlImageUploadPath = [NSString stringWithFormat:@"%@%@",sqlImageUploadPathOne,sqlImageUploadPathTwo];

        //testLabel.text = @"Uploading...";

        // Display Image in UIImageView (uploadImageHidden)
        UIImage *attemptImage = [UIImage imageNamed:sqlImageUploadPath];
        [uploadImageHidden setImage:attemptImage];



        // Upload to server
        NSData *imageData = UIImageJPEGRepresentation(uploadImageHidden.image, 90);
        NSString *urlStringOne = @"http://myflashpics.com/iphone_processes/upload.php?album=";
        NSString *urlStringTwo = @"&id=";
        NSString *urlString = [NSString stringWithFormat:@"%@%@%@%@",urlStringOne,getAlbumID,urlStringTwo,theUserID];

        NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
        [request setURL:[NSURL URLWithString:urlString]];
        [request setHTTPMethod:@"POST"];

        NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
        NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
        [request addValue:contentType forHTTPHeaderField:@"Content-Type"];

        NSMutableData *body = [NSMutableData data];
        [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
        [body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"userfile\"; filename=\".jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
        [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
        [body appendData:[NSData dataWithData:imageData]];
        [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
        [request setHTTPBody:body];

        NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
        NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

        //NSLog(@"%@", returnString);

        if ([returnString rangeOfString:@"yes"].location == NSNotFound) {
            // Fail
        } else {
            // Delete image if successful
            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
            NSString *documentsDirectoryPath = [paths objectAtIndex:0];
            NSString *myFilePath = [documentsDirectoryPath stringByAppendingPathComponent:sqlImageUploadPathTwo];
            NSFileManager *fileManager = [NSFileManager defaultManager];
            [fileManager removeItemAtPath:myFilePath error:NULL];
            [database executeNonQuery:@"DELETE FROM processes WHERE image=?", sqlImageUploadPathTwo];

            // Get Photo ID
            NSArray *myWords = [returnString componentsSeparatedByString:@" "];
            NSString *photoID = [myWords objectAtIndex:1]; 
            NSString *usernameID = [myWords objectAtIndex:2]; 

            NSString *defaultName = @"Photo uploaded from the flashpics iPhone application";

            // Get Thumbnail URL
            NSString *thumbnailURLOne = @"http://myflashpics.com/users/";
            NSString *thumbnailURLTwo = @"/pictures/thumbnails/";
            NSString *thumbnailURLThree = @".jpg";
            NSString *thumbnailURL = [NSString stringWithFormat:@"%@%@%@%@%@",thumbnailURLOne,usernameID,thumbnailURLTwo,photoID,thumbnailURLThree];

            // Download thumbnail
            //NSLog(@"Downloading...");
            UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:thumbnailURL]]];
            //NSLog(@"%f,%f",image.size.width,image.size.height);
            NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
            //NSLog(@"%@",docDir);
            //NSLog(@"saving jpeg");
            NSString *jpegFilePath = [NSString stringWithFormat:@"%@/%@_thumbnail.jpg",docDir,photoID];
            NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 0.2f)];//1.0f = 100% quality
            [data2 writeToFile:jpegFilePath atomically:YES];
            //NSLog(@"saving image done");
            [image release];

            // Put in database
            NSString *thumbnailEnd = @"_thumbnail.jpg";
            NSString *thumbnailLocation = [NSString stringWithFormat:@"%@%@",photoID,thumbnailEnd];

            int theCount = 0;
            NSArray *getUserIDInfotoo = [database executeQuery:@"SELECT * FROM images WHERE id=?",photoID];
            for (NSDictionary *getUserIDRowtoo in getUserIDInfotoo) {
                theCount++;
            }

            if (theCount == 0) {
                [database executeNonQuery:@"INSERT INTO images (id, name, thumbnail, album) VALUES (?, ?, ?, ?)", photoID, defaultName, thumbnailLocation, getAlbumID];
            }
            //[NSThread detachNewThreadSelector:@selector(updateImages) toTarget:RootViewController withObject:nil];
            //myTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector: @selector(updateImages) userInfo: nil repeats: NO];
        }

        [request release];
        [returnString release];

    }

    //NSLog([rowtwo valueForKey:@"image"]);
    //NSLog([rowtwo valueForKey:@"album"]);
}


[pool release];

// Stop the UIActivity in the top bar
TableViewAppDelegate *dataCeter = (TableViewAppDelegate *)[[UIApplication sharedApplication] delegate];
if ([dataCeter.dataTen isEqualToString:@""]) {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
}

Edit 2:

Where the startUploads gets called (different .m)

processViewController *processTable = [[processViewController alloc] initWithNibName:@"processView.xib" bundle:nil];
[processTable startUploads];
[processTable release];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:38:40+00:00Added an answer on May 21, 2026 at 5:38 am

    More code would be helpful but here are some suggestions:

    1. Check if startUploads is being called before the view is loaded. The view will only be loaded when it is accessed for the first time to be added to a superview.

    2. Consider initializing processList in your init method instead of viewDidLoad both to solve #1 and b/c the view can loaded & unloaded by iOS independently of the lifecycle of the viewController (depending on what other views you are displaying and whether any memory warnings occur).

    3. Make sure you are releasing processList in dealloc. You only need to release it in viewDidUnload if it is recreated and loaded in viewDidLoad.

    Your code sample doesn’t show when startUploads is being called and you aren’t adding any items to processList so it’s hard to tell if the above is relevant. Post some more code and I’ll revise my answer accordingly.

    good luck!

    [EDIT: added example code]

    The code fragments you posted are not a complete implementation of a view controller and the associated objects that interact with it. Given the code I have seen, your application design does not conform to MVC (Model/View/Controller) design pattern and I would be doing things a bit differently. However, I don’t want to make assumptions about code I haven’t seen or your ultimate intent or ability as a developer. I can’t write your app for you, just trying to directly help you with the specific question you asked regarding why your NSMutableArray property remains null after the startUploads action completed. With that in mind, here are my edits to the code you posted:

    processViewController.m – add the following:

    - (id)initWithNibNamed:(NSString *)nibName bundle:(NSBundle *)bundle {
        self = [super initWithNibNamed:nibName bundle:bundle];
        if (self) {
            processList = [[NSMutableArray alloc] init];
        }
        return self;
    }
    
    - (void)dealloc {
        self.processList = nil;
        [super dealloc];
    }
    

    different.m

    - (void)displayProcessVC {
        ProcessViewController *processVC = [[ProcessViewController alloc] initWithNibNamed:@"processView.xib" bundle:nil];
        NSLog(@"Different:displayProcessVC BEFORE STARTING UPLOAD, processList = %@", processVC.processList);
        [processVC startUploads];
        NSLog(@"Different:displayProcessVC AFTER STARTING UPLOAD, processList = %@", processVC.processList);
        // would normally present process VC here
        [processVC release];
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView that's populated using core data & sqlite. I'd like to
I have a UITableView that is being populated from an NSMutable array that has
I have a UILabel in a custom UITableViewCell that gets resized when the device
I have a UITableView that represents a list of objects, I'd like the user
I have a UITableView that has about 20 cells. Each has a UILabel within,
Is it possible to have a uitableview that when in editing mode it shows
I have a UITableView with cells that contain a UISwitch control. It's similar to
I have a custom UITableView cell that sports an Image, and a headline. I
I've been banging my head on this one for a while and I figured
been having this problem for a few days now and can't seem to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.