AddSkipBackupAttributeToItemAtURL & # 8594; NSString parameter?

To follow the storage guidelines, I have to use the method below to add a flag so that it doesn't return it to iCloud. However, the parameter here is for NSURL. I need to pass it as an NSString, e.g. from a string

return [[self offlineQueuePath] stringByAppendingPathComponent:@"SHKOfflineQueue.plist"]; 

Here is a method that accepts a URL.

  - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL { if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1 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; } else { // iOS >= 5.1 NSError *error = nil; [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error]; return error == nil; } } 

In any case, how would I modify the above method to achieve the same result, taking NSString as a parameter?

Thanks!

0
source share
2 answers

You do not need to change the method. Convert your string to a URL.

 NSURL *url = [NSURL URLWithString:@"your string"]; 
+2
source

Use this method

  NSURL *pathURL113= [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@",Your string]]; 

This is the perfect code.

0
source

All Articles