2012-06-22 4 views

답변

1

을 : 모든 파일을 앱 번들에서는

그래서 내가 좋아하는 파일의 .epub 검색, 액세스 할 수 없습니다 이 방법.

NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; 
    NSFileManager *manager = [NSFileManager defaultManager]; 
    NSDirectoryEnumerator *direnum = [manager enumeratorAtPath:bundleRoot]; 

    NSString *filename; 

    while ((filename = [direnum nextObject])) { 


     if ([filename hasSuffix:@".epub"]) { //change the suffix to what you are looking for 


      [arrayListofEpub addObject:[filename stringByDeletingPathExtension]]; 


     } 

    } 
4

아니요, 불가능합니다.

apps sandbox의 디렉토리를 제외하고는 파일 시스템 액세스가 없으므로

모든 앱은 샌드 박스와 함께 사용하는 파일을 저장해야합니다. iOS에 앱에 .epub 개의 파일이있을 수 있다고 말하면됩니다. 그러면 사용자가 앱에서 이메일 등의 파일을 열 수 있습니다. 당신은 당신이 ePub 파일은 응용 프로그램 번들 내부에 저장하지 열려 의미하는 경우

1

는, 당신은

@rckoenes 응답으로
2

, 그것은 수 없습니다 만 앱 샌드 박스 내부의 파일에 액세스 할 수 있습니다, 캔트 앱 번들 이외의 파일 시스템에 액세스 할 수 있습니다.

당신은이 같은 앱 번들에있는 파일에 액세스 할 수 있습니다 다음 @rckoenes 당으로

NSString *bundlePathName = [[NSBundle mainBundle] bundlePath]; 
NSError *error; 
NSArray *bundleContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundlePathName error:&error]; 

for (NSString *currentItem in bundleContents) { 
    if ([currentItem rangeOfString:@"." options:NSBackwardsSearch].location != NSNotFound) { 
     int tempIndex = (int)([fileName rangeOfString:@"." options:NSBackwardsSearch].location); 
     tempIndex++; 
     NSString *aStrExtension = [[fileName substringWithRange:NSMakeRange(tempIndex, [fileName length]-tempIndex)] lowercaseString]; 

     if ([aStrExtension isEqualToString:@"epub"]) { 

      //Add this file to an array, to make it available for choosing and view its details 
     } 
    } 
} 
관련 문제