I've the following code:
The code above is beging executed when i click a button (it's not really the button action but within the button action, the function above is being executed).Code:- (BOOL) setNewPicturePath { NSString *tmpPath = [[NSString alloc] init]; NSString *chkTmpPath = [[[NSString alloc] init] autorelease]; NSFileManager *pictureFileManager = [[NSFileManager alloc] init]; pictureFileManager = [NSFileManager defaultManager]; BOOL resultFilecheck = YES; int fileRenameCounter = 1; tmpPath = @"/location/which/doesnt/really/mather"; resultFilecheck = [pictureFileManager fileExistsAtPath:NSHomeDirectory()]; chkTmpPath = tmpPath; while(resultFilecheck == YES) { if(fileRenameCounter > 59) { NSLog(@"[ERROR] Failed to create new savePicturePath"); return NO; } // File already exists, try to create a new one and check if that file is available NSLog(@"[WARNING] Trying to create a new filepath because the following file already exists: %@", chkTmpPath); chkTmpPrefix = [NSString stringWithFormat:@"_%@.jpg", fileRenameCounter]; chkTmpPath = [tmpPath stringByReplacingOccurrencesOfString:@".jpg" withString:chkTmpPrefix]; pictureFileManager = [NSFileManager defaultManager]; resultFilecheck = [pictureFileManager fileExistsAtPath:chkTmpPath;] fileRenameCounter++; } return YES; }
The compiler gives no warnings/errors and the application is succesfully being executed on my iPhone 3G (2.0.1). At the moment i click on the button, the application hangs and the console in Xcode gives the error "EXC_BAD_ACCESS". I know this error is caused by a memory error. Tried everything i could find on the internet but nothing helps.
I know the error is caused at the moment the line "chkTmpPrefix = [NSString stringWithFormat:@"_%@.jpg", fileRenameCounter];" is being executed.
I hope you guys can help me with this one



LinkBack URL
About LinkBacks








Reply With Quote
Bookmarks