Crash during file save

Member
Posts: 102
Joined: 2005.01
Post: #1
Crash while generating temporarly files

Code:
NSString *path = [@"~/Desktop/.temp" stringByExpandingTildeInPath];
    path = [NSString stringWithFormat:@"%@/%@", path, [[source objectAtIndex:selected] name]];
    
    NSLog(path);
    
    [tempData writeToFile:path atomically:NO];


the logged path is /Users/admin/Desktop/.temp/animal.rtf

i also have tried this

Code:
NSString *path = [@"~/Desktop/.temp" stringByExpandingTildeInPath];
    path = [NSString stringWithFormat:@"\"%@/%@\"", path, [[source objectAtIndex:selected] name]];
    
    NSLog(path);
    
    [tempData writeToFile:path atomically:NO];


i know that the NSData is fine because this code worked earlier, then i messed with the path stuff and it stopped working

when i go and look in .temp there is nothing in it
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #2
Did you run a fileExistsAtPath: to verify that it is correctly finding the directory.

Try something of this nature, it sounds like the path isnt working for you.

NSFileManager *manager = [NSFileManager defaultManager];
if(![manager fileExistsAtPath: path])
{//Failed
}

This should help you understand what is failing a little better

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #3
Crash info (backtrace, failed assertions, and the like) are very useful too. Are you sure that you have no null pointers lying around? Also, NSLog(path) is bad practice - what if you have a path with a % symbol in it? You should NSLog(@"%@",path) instead.

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #4
werid. i left the house came back 2 hours later and ALL the stuff it used to crash on (spaces in name, spaces in file) are gone it works regardless......

no code changes at all.....
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #5
that happens to me a lot. i have so much source code on this computer Sad i have so many duplicates of the same projects, and copies and etc Sad

I need source control Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  save data of the app, and not loose them if i update the app sefiroths 2 3,052 Oct 16, 2012 12:01 PM
Last Post: sefiroths
  can photoshop save a png with only alpha channel? sefiroths 8 10,348 Jan 20, 2011 01:49 AM
Last Post: sefiroths