Post

Replies

Boosts

Views

Created

performDrop returns true, but drag image animates away
I have a view that conforms to DropDelegate. When a file is dragged from the Finder and dropped on the view, the performDrop(info:) method successfully extracts a URL from the item provider and returns true, but the drag image slides away as if the drop had been rejected. Why? func performDrop(info: DropInfo) -> Bool { bgColor = .yellow let providers = info.itemProviders(for: [.fileURL]) print("performDrop, providers: \(providers.count)") if let aProvider = providers.first { if aProvider.hasItemConformingToTypeIdentifier(UTType.url.identifier) { aProvider.loadItem(forTypeIdentifier: UTType.url.identifier) { (item, error) in if let error = error { print("Error retrieving item provider data: \(error.localizedDescription)") return } if let url = item as? URL { print("Received file URL (from Data.1): \(url)") } else if let data = item as? Data, let url = URL(dataRepresentation: data, relativeTo: nil) { print("Received file URL (from Data.2): \(url)") } } } } return true }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
0
163
Feb ’26
static analyzer error in std::sort
I'm getting a static analysis warning on the following code. I don't think it could be my error, but I guess it's more likely a static analysis false positive than a C++ standard library bug. The warning says "Method called on moved-from object of type 'std::basic_string'". Tested in Xcode 26.5 RC. Reported as FB22735405. #include <algorithm> #include <string> #include <vector> #include <CoreFoundation/CoreFoundation.h> template < class traits = std::char_traits<char>, class Allocator = std::allocator<char> > struct UTF8StringLess { bool operator()( const std::basic_string<char, traits, Allocator>& inFirst, const std::basic_string<char, traits, Allocator>& inSecond ) const; }; template<class traits, class Allocator> inline bool UTF8StringLess<traits, Allocator>::operator()( const std::basic_string<char, traits, Allocator>& inFirst, const std::basic_string<char, traits, Allocator>& inSecond ) const { CFStringRef theFirst = ::CFStringCreateWithCString( nullptr, inFirst.c_str(), kCFStringEncodingUTF8 ); CFStringRef theSecond = ::CFStringCreateWithCString( nullptr, inSecond.c_str(), kCFStringEncodingUTF8 ); CFComparisonResult compResult = ::CFStringCompare( theFirst, theSecond, kCFCompareCaseInsensitive ); bool isLess = (compResult == kCFCompareLessThan); ::CFRelease( theFirst ); ::CFRelease( theSecond ); return isLess; } int main(int argc, const char * argv[]) { std::vector<std::string> names{ "obey", "Zorro", "can" }; std::sort( names.begin(), names.end(), UTF8StringLess() ); return EXIT_SUCCESS; }
6
0
45
3d
performDrop returns true, but drag image animates away
I have a view that conforms to DropDelegate. When a file is dragged from the Finder and dropped on the view, the performDrop(info:) method successfully extracts a URL from the item provider and returns true, but the drag image slides away as if the drop had been rejected. Why? func performDrop(info: DropInfo) -> Bool { bgColor = .yellow let providers = info.itemProviders(for: [.fileURL]) print("performDrop, providers: \(providers.count)") if let aProvider = providers.first { if aProvider.hasItemConformingToTypeIdentifier(UTType.url.identifier) { aProvider.loadItem(forTypeIdentifier: UTType.url.identifier) { (item, error) in if let error = error { print("Error retrieving item provider data: \(error.localizedDescription)") return } if let url = item as? URL { print("Received file URL (from Data.1): \(url)") } else if let data = item as? Data, let url = URL(dataRepresentation: data, relativeTo: nil) { print("Received file URL (from Data.2): \(url)") } } } } return true }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
0
Boosts
0
Views
163
Activity
Feb ’26
static analyzer error in std::sort
I'm getting a static analysis warning on the following code. I don't think it could be my error, but I guess it's more likely a static analysis false positive than a C++ standard library bug. The warning says "Method called on moved-from object of type 'std::basic_string'". Tested in Xcode 26.5 RC. Reported as FB22735405. #include <algorithm> #include <string> #include <vector> #include <CoreFoundation/CoreFoundation.h> template < class traits = std::char_traits<char>, class Allocator = std::allocator<char> > struct UTF8StringLess { bool operator()( const std::basic_string<char, traits, Allocator>& inFirst, const std::basic_string<char, traits, Allocator>& inSecond ) const; }; template<class traits, class Allocator> inline bool UTF8StringLess<traits, Allocator>::operator()( const std::basic_string<char, traits, Allocator>& inFirst, const std::basic_string<char, traits, Allocator>& inSecond ) const { CFStringRef theFirst = ::CFStringCreateWithCString( nullptr, inFirst.c_str(), kCFStringEncodingUTF8 ); CFStringRef theSecond = ::CFStringCreateWithCString( nullptr, inSecond.c_str(), kCFStringEncodingUTF8 ); CFComparisonResult compResult = ::CFStringCompare( theFirst, theSecond, kCFCompareCaseInsensitive ); bool isLess = (compResult == kCFCompareLessThan); ::CFRelease( theFirst ); ::CFRelease( theSecond ); return isLess; } int main(int argc, const char * argv[]) { std::vector<std::string> names{ "obey", "Zorro", "can" }; std::sort( names.begin(), names.end(), UTF8StringLess() ); return EXIT_SUCCESS; }
Replies
6
Boosts
0
Views
45
Activity
3d