NSMutableArrayにパスを追加する必要があるアプリケーションとwriteToFileを持っています。NSMutableArrayに書き込まない
int r = arc4random() % 100;
int s = arc4random() % 100;
int e = arc4random() % 100;
NSLog(@"%i%i%i.MOV", r, s, e);
NSString * tempFileName = [NSString stringWithFormat:@"%i%i%i.MOV", r, s, e];
NSString * tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
NSString * documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString * storePath = [documentsDirectory stringByAppendingPathComponent:tempFileName];
NSError *error = nil;
[[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:tempFilePath]
toURL:[NSURL fileURLWithPath:storePath]
error:&error];
if (error) {
NSLog(@"%@", error);
}
NSLog(@"Old File path : %@", tempFilePath);
NSLog(@"New File path : %@", storePath);
dayCounter ++;
videoDayCounter = [[NSMutableArray alloc] initWithContentsOfFile:dayCounterPath];
NSLog(@"DayCounter INIT");
[videoDayCounter addObject:dayCounter];
[videoDayCounter writeToFile:dayCounterPath atomically:YES];
NSLog(@"dayCounter wrote to file"); '
allVideos = [[NSMutableArray alloc] initWithContentsOfFile:allVideosPath];
NSLog(@"AllVideosINIT");
[allVideos addObject:storePath];
NSLog(@"array: %@", allVideos);
[allVideos writeToFile:allVideosPath atomically:YES];
[videoCount setText:[allVideos count]];
[daysLabel setText:[videoDayCounter count]];
[self dismissModalViewControllerAnimated:YES];
[picker release];
NSLog for allVideosがNULLを返しています。
私は
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *allVideosPath = [documentsDirectory stringByAppendingPathComponent:@"allVideos.plist"];
NSString *dayCounterPath = [documentsDirectory stringByAppendingPathComponent:@"dayCount.plist"];
BOOL booleanAllVideos;
BOOL booleanDayCounter;
NSFileManager *fileManager = [NSFileManager defaultManager];
booleanAllVideos = [fileManager fileExistsAtPath:allVideosPath];
booleanDayCounter= [fileManager fileExistsAtPath:dayCounterPath];
if(booleanAllVideos == NO)
{
NSMutableArray *allVideos = [[NSMutableArray alloc] initWithCapacity:3];
[allVideos writeToFile:allVideosPath atomically:YES];
}
if(booleanDayCounter == NO)
{
NSMutableArray *videoDayCounter = [[NSMutableArray alloc] initWithCapacity:3];
[allVideos writeToFile:dayCounterPath atomically:YES];
}
によってアプリの起動時にallVideosPathを作成しようとしました。しかし、私はそれが動作しないと思いますか?
ありがとうございました!
dayCounterPathが最初のコードスニペットで定義されていないようです - viewdidloadと同じ設定ですか? – jrturton
アームはありますか?何をすべきか教えてください。 –
dayCounterとは何ですか?あなたは++でインクリメントしますが、それをオブジェクトのように配列に追加しますか? – jrturton