Note that there are some explanatory texts on larger screens.

plurals
  1. PONSMutableArray returns null?
    primarykey
    data
    text
    <p>I have a UITableView that gets populated my a NSMutableArray. This is how I have it set up in my .h</p> <pre><code>@interface processViewController : UIViewController &lt;UITableViewDelegate, UITableViewDataSource&gt; { NSMutableArray *processList; } @property (copy, readwrite) NSMutableArray *processList; </code></pre> <p>and my .m</p> <pre><code>@synthesize processList; -(void)viewDidLoad { processList = [[NSMutableArray alloc] init]; } </code></pre> <p>I put a NSLog on it on the viewDidLoad, and it displays just fine. But after I run a action, the <code>processList</code> array returns <code>null</code>. Any ideas why?</p> <p>Thanks<br>Coulton</p> <p><strong>EDIT 1:</strong></p> <pre><code>- (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 = @"&amp;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; } } </code></pre> <p><strong>Edit 2:</strong></p> <p>Where the startUploads gets called (different .m)</p> <pre><code>processViewController *processTable = [[processViewController alloc] initWithNibName:@"processView.xib" bundle:nil]; [processTable startUploads]; [processTable release]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload