c'est le code objectif cpourquoi je ne reçois pas le chemin d'URL correct dans OSX rapide
dispatch_once(&onceToken, ^{
formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"YYYYMMDDHHmmss"];
homeDir = [NSURL fileURLWithPath:[@"~/xyz/" stringByExpandingTildeInPath]];
});
NSString* date = [formatter stringFromDate:[NSDate date]];
self.file = [[homeDir URLByAppendingPathComponent:[@"xyz-" stringByAppendingString:date]] URLByAppendingPathExtension:@"m4a"];
NSLog(@" self.file = %@", self.file);
quand j'ai essayé de convertir ce code SWIFT 3, je ne reçois pas l'URL correcte .. Can quelqu'un vous aide?
This is the path I get
~/xyz/xyz-201710291142410.m4a -- file:///Users/xyz/Library/Developer/Xcode/DerivedData/xyz-guhahcdeflytfhhdsxtsrucmqqnv/Build/Products/Debug/
Mais ceci est le chemin que je veux
fichier: ///Users/xyz/xyz/xyz-201710291142410..m4a
ma syntaxe rapide a échoué
formatter = DateFormatter()
formatter?.dateFormat = "YYYYMMDDHHmmss"
let urlS = "~/xyz/"
// NSURL.fileURL(withPath: urlS.stringByExpandingTil)
var homeDir = URL.init(fileURLWithPath: urlS) //URL.appendingPathComponent(URL(string: urlS))
let date: String? = formatter?.string(from: Date())
let file = homeDir.appendingPathComponent("xyz-" + (date!)).appendingPathExtension("m4a")
est l'application sandbox? Si oui, vous n'avez pas accès au répertoire personnel. – vadian
pouvez-vous me dire comment le savoir? Je suis assez nouveau à OSX. Je reçois le chemin lorsque j'utilise le code c objectif .. Mais je veux utiliser le code rapide. – solArise
ok pas d'importance J'ai corrigé mon problème – solArise