ICL1901
ICL1901

Reputation: 7778

xCode ios How to write a mutable array to a file on the desktop?

I have a one-time need to create a file from an iOS mutable array. The array will be a short animated drawing.

That will be input to an app.

I write the array, and redraw it in the app, so I know that it's getting populated.

I've tried to do something as simple as this:

- (void) writeFile {
//CREATE FILE
NSLog(@"%s", __FUNCTION__);
[writeArray writeToURL:[NSURL fileURLWithPath:[@"~/Desktop/animation.data" stringByExpandingTildeInPath]] atomically:NO];
}

but I must be doing something wrong, as no file appears..

As the file is small (4-8K), maybe I should take a different approach?

Any help will be appreciated.

Upvotes: 0

Views: 875

Answers (1)

Rob Napier
Rob Napier

Reputation: 299355

Of course this won't work on the device, but I assume you're just trying to work in the Simulator for some kind of testing. fileURLWithPath: doesn't expand ~. You need a full path here. None of the path searching routines is going to point into your user folder in any case, since that doesn't exist on iOS.

Upvotes: 1

Related Questions