Results 1 to 2 of 2
Discuss [iPhone 2.0.x] EXC_BAD_ACCESS when clicking on a button at the Free Toolchain Software (Cydia App's) - Hackint0sh.org; I've the following code: Code: - (BOOL) setNewPicturePath { NSString *tmpPath = [[NSString alloc] init]; ...
  1. #1
    Rookie Array

    Join Date
    Aug 2008
    Posts
    12
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default [iPhone 2.0.x] EXC_BAD_ACCESS when clicking on a button

    I've the following code:

    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 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).
    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



  2. #2
    Rookie Array

    Join Date
    Aug 2008
    Posts
    12
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Problem fixed, i changed %@ to %i. I didn't know there was a difference with string conversions.

 

 

Similar Threads

  1. Replies: 2
    Last Post: 01-03-2009, 09:19 AM
  2. 3rd party apps exiting upon clicking
    By zulu73 in forum iPhone "2G" (Rev. 1)
    Replies: 0
    Last Post: 10-26-2007, 12:35 AM
  3. Replies: 5
    Last Post: 09-16-2007, 11:43 PM
  4. Replies: 1
    Last Post: 09-06-2007, 06:02 AM
  5. Hard drive clicking after sleep resume
    By systimax in forum Archiv (Leopard)
    Replies: 2
    Last Post: 06-20-2007, 05:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 12:31 PM.
twitter, follow us!