프로그래밍/iOS

iCloude관련 리젝시

백룡화검 2012. 4. 24. 15:01

이미 관련글이 올라와 있는지는 모르겠지만...


아이클라우드 약관이 생기면서,.,.

도큐멘트 폴더에 저장을 하게 되면 리젝을 먹는 경우가 있습니다.

애플에서는 도큐멘트 폴더를 아이클라우드가 가져가지 못하게 하는 코드를 알려주더군요.

이 코드는 iOS5.0.1버전 부터 지원합니다.

이렇게 사용해 보고 아이클라우드로 다시 백업을 해보니~

가져가지 않았더군요.....

5.0버전 이하는 아이클라우드가 없으니까 처리를 안해줘도 되고...
5.0.1버전부터 지원하는 거라....
5.0은 어떻게 하나 걱정을 했는데...

일단 5.0.1이상만 처리해서 올렸는데 통과는 되더군요...

간단한 팁이었습니다....

 //iCloud 막을 Document경로 설정

    NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];

    NSURL *pathURL= [NSURL fileURLWithPath:documentPath];

    

    NSLog(@"%@",documentPath);

    

    if([[[UIDevice currentDevice] systemVersion] floatValue] > 5.0f){

        [self addSkipBackupAttributeToItemAtURL:pathURL];

    }else{

        NSLog(@"CANNOT - CUZ VERSION IS UNDER 5.0.1");

    }



//밑으로 애플에서 알려준 코드 URL에 경로
그래서 위에서 5.0.1버전 부터 호출 하도록하고
경로를 설정.

//Cloud Data 백업 방지...

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL

{

    const char* filePath = [[URL path] fileSystemRepresentation];

    

    const char* attrName = "com.apple.MobileBackup";

    u_int8_t attrValue = 1;

    

    int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);

    return result == 0;

}