In a MacOs application, Is it possible to navigate to a connected iOS device?
I have a trusted iPad that I can see in the finder, however I cannot see it in my application using an NSOpenPanel.
Is it possible to do so?
Thanks
Post
Replies
Boosts
Views
Activity
I'm very confused by this.
I am trying to take a directory of image files from an iPhone (live photos, videos, regular still images, portrait mode images, etc.) and import them into an album in the Photo Library on an iOS device.
The code I've written seems to do exactly what I want it to – it creates images in an album that I've created. That's all good.
However, although the Photos app shows the images as being "Portrait Mode", for example, the are not editable as Portrait Mode images... ie. I cannot change the depth effects of the images.
If I take one of the HEIC files I imported, that was taken in Portrait Mode, and just drop it onto Photos on an iPad it will import with the ability to be edited, as I would expect.
If I import the image programmatically, the way I'm doing it, it recognizes that it is a Portrait Mode image but I cannot edit the depth of field effect in Photos.
Here is the code I'm using to import:
func createStillAssetOnAlbum(asset: URL, album: PHAssetCollection) {
let photoURL = asset
PHPhotoLibrary.shared().performChanges ({
let creationRequest = PHAssetCreationRequest.forAsset()
let placeHolderAsset = creationRequest.placeholderForCreatedAsset
creationRequest.addResource(with: .photo, fileURL: photoURL, options: nil)
guard let albumChangeRequest = PHAssetCollectionChangeRequest(for: album) else {
print("album change request has failed")
return
}
albumChangeRequest.addAssets([placeHolderAsset] as NSArray)
}, completionHandler: { success, error in
if success {
print("photo (and adjustments) saved successfully")
self.importCount += 1
}
else if let e = error {
print("error saving photo (and adjustment): \(e)")
self.nonImportedImageCount += 1
}
})
}
Any thoughts as to why an image file that I drop onto an iPad Photos app, that is editable as a portrait mode photo cannot be edited as a portrait mode photo when imported via the method I'm using?
Thank you!
I am using the code below to import images into a Photos Library. The code works for JPGs and HEICs but when it encounters Apple ProRaw (DNG) files it give the following error messages:
Error Domain=PHPhotosErrorDomain Code=3302
findWriterForTypeAndAlternateType:119: unsupported file format 'com.adobe.raw-image'
Here is the code:
func createPhotoOnAlbum(photo: UIImage, album: PHAssetCollection) {
PHPhotoLibrary.shared().performChanges({
// Request creating an asset from the image
let createAssetRequest = PHAssetChangeRequest.creationRequestForAsset(from: photo)
// Request editing the album
guard let albumChangeRequest = PHAssetCollectionChangeRequest(for: album) else {
print("album change request has failed")
// Album change request has failed
return
}
// Get a placeholder for the new asset and add it to the album editing request
guard let photoPlaceholder = createAssetRequest.placeholderForCreatedAsset else {
// Photo Placeholder is nil
return
}
albumChangeRequest.addAssets([photoPlaceholder] as NSArray)
}, completionHandler: { success, error in
if success {
// Saved successfully!
print("saved successfully")
self.importCount += 1
}
else if let e = error {
// Save photo failed with error
print("error saving: \(error)")
}
else {
print("error -> ")
// Save photo failed with no error
}
})
These are definitely unedited ProRaw DNGs.
On a Mac they can be imported into a Photos Library using the "Import" menu command.
On an iPad they can be brought into the Photos Library by selecting them in the file system on the iPad, tapping Share, then tapping Save Images.
Thank you for any assistance with this.
I am using an AVPlayerView and I'm trying to call the beginTrimming method. However it isn't working (ie. not entering trimming mode), so I checked its .canBeginTrimming property and found that it is false.
The .mov files I am using are local and I'm accessing them via their urls. They load and play properly, I just can't enter trimming mode. (Also, if I open the same files in QuickTimePlayer I can trim them.)
The research I've found says: "This property value is false if the current controls style doesn’t support trimming, the media is content protected, or when playing HTTP Live Streaming media.
The .mov files I am using are local and I'm accessing them via their urls. They load and play properly, I just can't enter trimming mode. (Also, if I open the same files in QuickTimePlayer I can trim them.)
I have an outlet to the AVPlayerView in my view controller. The control's style is set to default and "show buttons" is set to Frame Stepping.
Why might the player I have set up not allow trimming?
Here is where I am loading the mov file, checking whether trimming is allowed and attempting to enter trimming mode:
func tableViewSelectionDidChange(_ notification: Notification) {
let row = movTableView.selectedRow
guard row != -1 else { return }
let selectedURL = movDict[allFilenames[row]]
print(selectedURL)
if let selectedURL {
let player = AVPlayer(url: selectedURL)
movPlayerView.player = player
if movPlayerView.canBeginTrimming {
print("medial player supports trimming")
} else {
print("media player does NOT support trimming")
}
movPlayerView.beginTrimming { result in
if result == .okButton {
print("trimming ended. ok pressed")
} else {
print("cancel pressed.")
}
}
}
}
Is it possible to combine two NSImages, one on top of another, specifying a blend mode? I have two images I would like to overlay, then display in an NSImageView.
I appreciate any guidance.
Thanks
I understand that your application cannot modify its app bundle.
I have an application (written in another development environment, that I'm porting to Swift).
It has a dummy file in its app bundle that I want to modify in some way. How would I go about it?
Can I copy an item out of the app bundle, modify it, then delete it?
Thanks for any suggestions.
This question shows research effort; it is useful and clear
0
I'm trying to implement a function to check the names of some subfolders for spelling. I have a test function, shown below. The folder names are in a [String] called listOfFolders.
I'm using guesses(forWordRange:in:language:inSpellDocumentWithTag:) and it seems to work in that it does show me recommended spellings of words that seem to be spelled incorrectly, however I want to ignore some words – and that doesn't seem to work.
func check() {
let words = listOfFolders.joined(separator: " ")
let spellChecker = NSSpellChecker.shared
spellChecker.setIgnoredWords(["Stills", "Video", "HEIC", "JPG", "EIP", "ARW", "IIQ", "NEF", "FFF", "CR2", "CR3", "RAF", "DNG"], inSpellDocumentWithTag: 0)
for word in listOfFolders {
let w = word
let start = 0
let end = w.count
let range : NSRange = NSRange(location: start, length: end)
let g = spellChecker.guesses(forWordRange: NSRange.init(location: start, length: end), in: String(w), language: nil, inSpellDocumentWithTag: 0)
print("w: \(w)")
print("g: \(g)")
}
}
Using Swift, I have an NSTableView with four columns.
Two of the columns have cells that I want the user to be able to edit.
In my Storyboard I have set the NSTextFieldCells to be
Behaviour: Editable
Action: Sent on End Editing
I have created an @IBAction function to receive the action from the NSTextFieldCell but it never fires.
Everything about the NSTableView appears to work as expected – it displays the values that it should, however when I edit the editable cells the action never fires (and the cell values do not change, of course.)
What am I overlooking?
Thanks
Has anyone had success installing exiftool under Big Sur (beta 2 is what I'm trying.)
I can run the installer (which isn't signed so right click/open works) but the installer kicks me out saying that it's from an unknown developer. Is there a similar way to override that check on a package installer?