2014-02-06 2 views
0

여기에 약간의 좌절 된 문제가 있습니다. 문제는 번들에서 내 응용 프로그램의 라이브러리 경로에 디렉토리를 복사하려고하지만 코드에서 수행 할 수 없습니다. 내가 디렉토리를 복사하기 전에번들에서 라이브러리로 디렉토리를 복사 할 수 없습니다.

enter image description here

, 난 번들 디렉토리의 내용을 확인하고 싶어하지만, 배열 반환 0 항목 : 디렉토리의 트리 여기 보이고있다. 내가 사용하는 코드는 다음과 같습니다

NSString * templatesBundlePath = [[NSBundle mainBundle] pathForResource:@"Templates" ofType:nil]; 
NSArray * packFolders = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:templatesBundlePath] includingPropertiesForKeys:[NSArray arrayWithObjects:NSURLIsDirectoryKey, nil] options:0 error:&error]; 

packfolders 0 항목이 포함되어 있습니다. 이 코드

NSFileManager *fm = [[NSFileManager alloc] init]; 

resultSize = [[[fm attributesOfItemAtPath:[[NSURL fileURLWithPath:templatesBundlePath] path] error:nil] objectForKey:NSFileSize] unsignedIntegerValue]; 

NSLog(@"Size: %lu", (unsigned long)resultSize); 

값 만 표시와 함께 번들 디렉토리의 크기를 확인하려고 할 때

NSString * templatesAppPath = NSApplicationSupportDirectoryPath(@"Templates"); 
[[NSFileManager defaultManager] copyItemAtPath:templatesBundlePath toPath:templatesAppPath error:&error]; 

:

과 포함 된 경우

내가이 코드를 복사하려고 0이 아닌 68, 파인더의 실제 크기는 200MB입니다.

내 것과 같은 문제가있는 사람이 있습니까? 누군가 나를 도울 수 있습니까?

감사합니다.

답변

1

프로젝트 폴더는 노란색으로, 폴더가 아니라 그룹입니다. 디렉토리 구조는 앱과 리소스를 번들로 제거 할 때 모든 파일이 묶음의 루트에 배치됩니다.

프로젝트에서 모든 그룹을 제거하고 폴더를 다시 프로젝트로 드래그하면 그룹 대신 폴더를 만듭니다.

enter image description here

+0

하이 @rckoenes, 들으을 다음 내가 너무 대상 그룹의 폴더에 복사 항목을 클릭해야 해요? –

+0

프로젝트로 드래그하는 디렉토리가 프로젝트 디렉토리 밖에있는 경우에만. – rckoenes

0

이 black.jpg 이미지 경로를 가져보십시오 :

있는 NSString * strpath = [있는 NSString stringWithFormat : "%의 @"@ [[NSBundle mainBundle] pathForResource : @ "템플릿"ofType : @ ""]]]; strpath = [strpath stringByAppendingString : @ "/"]; strpath = [strpath stringByAppendingString : @ "80s"]; strpath = [strpath stringByAppendingString : @ "/"]; strpath = [strpath stringByAppendingString : @ "80s_a-team"]; strpath = [strpath stringByAppendingString : @ "/"]; strpath = [strpath stringByAppendingString : @ "black"]; strpath = [strpath stringByAppendingString : @ ". jpg"];

0

시도 답변을 코드

NSArray *libraryPath=NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); 
     NSString *directoryPath = [libraryPath objectAtIndex:0]; 
     NSString *imagePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Templete"]; 

       // Copy the image Folder from the package to the users filesystem 
       [fileManager copyItemAtPath:imagePathFromApp toPath:directoryPath error:nil]; 
관련 문제