オーディオ ファイルのリストをドキュメント ディレクトリに格納してから取得する作業を行っています。
これと一緒にオーディオファイルのリストが表示され、 name のファイルが表示されます@".DS_Store"
。コンテンツを取得している間、ドキュメント ディレクトリのこのファイルを残しておきたいと思います。
@".DS_Store"
これを配列から削除するか、チェックを適用する以外に、オーディオリストを取得しているときにこれを取り除く方法はありますか?
この理由は正確には何ですか。
#pragma mark - Saving Audio in Document Directory
-(void)saveAudioinDocumentDirectory:(ASIHTTPRequest *)theRequest
{
/*save the Audio file in Document Directory */
NSFileManager *fileManager=[NSFileManager defaultManager];
NSLog(@"GOT THE SIZe OF AUDIO %d",[[theRequest responseData] length]);
NSLog(@"AUDIO ID IS %@",[[theRequest userInfo] valueForKey:@"audioIndex"]);
/*Get the Path to Application Documents Directory*/
NSArray *docDir=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
/*append the neccessary file extension */
NSString *filepathStr=[NSString stringWithFormat:@"/%@/%@.mp3",docDir,[NSString stringWithFormat:@"%@",[[theRequest userInfo] valueForKey:@"audioIndex"]]];
/*Check if my crrent file exists in the Documents Directory*/
if(![fileManager fileExistsAtPath:filepathStr])
{
/* file doesnt exists */
/*create a NSdata of File*/
NSData *data=[NSData dataWithData:[theRequest responseData]];
NSLog(@"%@",filepathStr);
if ([data length] >0 ){
/*write the File at the Location in Documents Directory */
[data writeToFile:filepathStr atomically:YES];
NSLog(@"Successfully saved the file to %@", filepathStr);
}
else if([data length] == 0)
{
NSLog(@"Nothing was downloaded.");
}
}
/*After saving fetch the path til documents Directory*/
NSArray *folders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
/*Get the Path for Files */
NSString *s=[folders objectAtIndex:0];
/*Fetch the list of Files stored in Documents Directory*/
NSArray *contents = [fileManager contentsOfDirectoryAtPath:s error:NULL];
NSLog(@"TOTAL NUMBER OF AUDIO FILES %d %@",[contents count],[contents objectAtIndex:0]);
if([Audiolistforstr isEqualToString:@"AudioListForIntro"])
{
// NSLog(@"Audiolistforstr@"IntroThirdRow" in reading audio from document Intro IS %@",Audiolistforstr);
/*Intro*/
[AudioListArrForIntro removeAllObjects];
[AudioListArrForIntro addObjectsFromArray:contents];
if([AudioListArrForIntro containsObject:@".DS_Store"])
{
[AudioListArrForIntro removeObject:@".DS_Store"];
}
NSLog(@"FINAL LIST %@",AudioListArrForIntro);
}
else if([Audiolistforstr isEqualToString:@"AudioListForCredits"])
{
// NSLog(@"Audiolistforstr@"IntroThirdRow" in reading audio from document credit IS %@",Audiolistforstr);
/*credits*/
[AudioListArrForCredits removeAllObjects];
[AudioListArrForCredits addObjectsFromArray:contents];
if([AudioListArrForCredits containsObject:@".DS_Store"])
{
[AudioListArrForCredits removeObject:@".DS_Store"];
}
NSLog(@"FINAL LIST %@",AudioListArrForCredits);
}
/* Did we find anything? */
if([Audiolistforstr isEqualToString:@"AudioListForIntro"])
{
// NSLog(@"Audiolistforstr@"IntroThirdRow" in reading audio fromRELOADNG TABLE Intro IS %@",Audiolistforstr);
/*Intro*/
if ([AudioListArrForIntro count] == 0)
{
}
else
{
UIView *vw=(UIView *)[self.view viewWithTag:ViewAddAudioIntroTag];
[(UITableView *)[vw viewWithTag:tblIntroAudioListTag] reloadData];
}
}
else if([Audiolistforstr isEqualToString:@"AudioListForCredits"])
{
// NSLog(@"Audiolistforstr@"IntroThirdRow" in reading audio fromRELOADNG TABLE Intro IS %@",Audiolistforstr);
/*Credits*/
if ([AudioListArrForCredits count] == 0)
{
}
else
{
/*AudioListForCredits*/
UIView *vw=(UIView *)[self.view viewWithTag:ViewAddAudioCreditsTag];
[(UITableView *)[vw viewWithTag:tblCreditsAudioListTag] reloadData];
}
}
}
どんな助けでも大歓迎です。
ありがとうヴィカス