Posts

Post not yet marked as solved
4 Replies
3.5k Views
Is there documentation for converting Data to any specific Type ?I'm trying to get & set Date Last Opened and came across a nice extension someone posted for getting & settings Extra Attributes ... https://stackoverflow.com/questions/38343186/write-extend-file-attributes-swift-example it's the first response. Found the attribute "com.apple.lastuseddate#PS" which comes back as Data. I tried searching Google but again didn't find much, just examples of turning Data into Strings. Would be nice to have a single document for any type ?I have no idea if this relates to the same thing but at the moment am using "NSMetadataItem(url: url)?.value(forAttribute: NSMetadataItemLastUsedDateKey) as? Date" which works fine although not sure about setting the attribute.
Posted
by Pendragon.
Last updated
.
Post not yet marked as solved
11 Replies
855 Views
My appologies for posting so much recently.Just having a mess around and probably far off from a decent result but if you get the idea of what I'm looking for then would appreciate a reply ...public enum anEnum { typealias thisway = (from: URL, to: URL) typealias thatway = Bool } static func test(_ aliashere: anEnum) { let this = aliashere... } let this: anEnum.thisway = (from: URL(fileURLWithPath: ""), to: URL(fileURLWithPath: "")) self.test(this)
Posted
by Pendragon.
Last updated
.
Post marked as solved
2 Replies
625 Views
Is this possible ? ...static func loadJSON<T>(_ url: URL, arrayType: T.Type) let json_array: [AnyObject] = try JSONDecoder().decode(Array<T>.self, from: json_data)Trying to make my loading func a bit more dynamic.
Posted
by Pendragon.
Last updated
.
Post marked as solved
4 Replies
1k Views
No idea if this is a bug if not why is it happening ? ...static func writeJSON(_ url: URL,_ array: [Array],_ completion: ((_ success: Bool,_ error: String) -> Void)?)Doing this works fine but ...static func writeJSON(_ url: URL,_ array: [Array]? = nil,_ completion: ((_ success: Bool,_ error: String) -> Void)?)Doesn't work ? Yet optional Parameters without the optional Completion work fine, just not both together.
Posted
by Pendragon.
Last updated
.
Post not yet marked as solved
0 Replies
805 Views
Trying to find the fastest way to check if a movie file (mp4 / m4v...) has Metadata Artwork. I have 2 different ways at the moment because I don't want to use AVMetadataIdentifier but the first seems to be faster than the second but both are kinda slow ...let ident: AVMetadataIdentifier = .commonIdentifierArtwork if let first: AVMetadataItem = AVMetadataItem.metadataItems(from: metadata, filteredByIdentifier: ident).first { return true } return falselet keyspace = AVMetadataKeySpace(rawValue: "itsk") let key = "covr" if let first_item = AVMetadataItem.metadataItems(from: metadata, withKey: key, keySpace: keyspace).first { return true } return falseI should add the url's come from Filemanager enumerated. Also for some reason every time either is ran I get big difference in time.
Posted
by Pendragon.
Last updated
.
Post not yet marked as solved
4 Replies
6.3k Views
Couldn't find anything for Swift just for C# https://stackoverflow.com/questions/10107140/how-do-i-measure-how-long-a-function-is-runningIs there anything I can use with Swift ?
Posted
by Pendragon.
Last updated
.
Post not yet marked as solved
4 Replies
1.6k Views
NSAlert same as NSOpenPanel have Style "Sheet" but this way is Asynchronous. Ideally want this to be Synchronous.For the NSAlert (buttons) I tried using Selector for Target/Action but realised there is no way to pass a Parameter, then wondered if I could get a return result from the func where the Alert is created but no as it's Async. Both the Alert & Open Panel I'm wanting to make as flexable as possible however doing this seems to have it's set-backs.Any suggestions / methods how to achieve this ?
Posted
by Pendragon.
Last updated
.