2015-10-05 1 views
0

Я выполняю эту функцию, чтобы сохранить UIDocument с включенным и отключенным iCloud, но, похоже, я пропустил оба броска. В частности, когда iCloud eanbled saveToURL возвращает false, и я понятия не имею, почему это так, учитывая, что документ не нуль, а путь разумный; это моя функция в общем:saveToURL в UIDocument возвращает false

func newFavorite(favorite: palinaModel) ->Bool { 
    if indexForPalina(favorite) != nil { 
     print("stop already favorite") 
     return false; 
    } 
// Save Stop 
    let baseURL = NSFileManager.defaultManager().URLForUbiquityContainerIdentifier(nil) 
    var favoriteURL:NSURL! 
    if (baseURL != nil) { 
     let favoritesURL = baseURL!.URLByAppendingPathComponent(pathComponent()) 
     favoriteURL = favoritesURL.URLByAppendingPathComponent(String(format:"Stop_%@", favorite.palina)) 
    } else { 
     let filePath = getFilePath() 
     favoriteURL=NSURL(fileURLWithPath: filePath) 
    } 
    let document = FavoriteStopDocument(fileURL:favoriteURL, favorite:favorite) 

// Add Bookmark To Bookmarks 
    self.favoriteElements.append(document) 
    print("favoriteUrl=" + favoriteURL.path!+" document="+document.favoriteStop!.palina) 
    document.saveToURL(favoriteURL, forSaveOperation:.ForCreating, completionHandler:{(success) in 
     if (success) { 
      print("Save succeeded."); 
     } else { 
      print("Save failed."); 
     } 
    }) 

    return true 
} 

Спасибо, что вы поддерживаете.

ответ

0

Я закончил тем, что сбросил UIDocument после того, как даже возможно потерял билет с Apple, и решил сохранить словарь как обычный NSUserDefault.