Skip to content

Commit 91e9841

Browse files
committed
Fix NSUUID::initWithUUIDBytes
Passing `None` doesn't work on older versions of Foundation.
1 parent 660ba46 commit 91e9841

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

framework-crates/objc2-foundation/src/uuid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl RefUnwindSafe for NSUUID {}
1313
impl NSUUID {
1414
/// The 'nil UUID'.
1515
pub fn nil() -> Retained<Self> {
16-
Self::initWithUUIDBytes(Self::alloc(), None)
16+
Self::from_bytes([0; 16])
1717
}
1818

1919
/// Create a new `NSUUID` from the given bytes.
@@ -33,7 +33,7 @@ impl NSUUID {
3333
/// assert_eq!(obj.as_bytes(), uuid.into_bytes());
3434
/// ```
3535
pub fn from_bytes(bytes: [u8; 16]) -> Retained<Self> {
36-
Self::initWithUUIDBytes(Self::alloc(), Some(&bytes))
36+
Self::initWithUUIDBytes(Self::alloc(), &bytes)
3737
}
3838

3939
#[cfg(feature = "NSString")]

framework-crates/objc2-foundation/translation-config.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ class.NSURL.bridged-to = "CoreFoundation.CFURL.CFURL"
312312
# TODO: Custom-define this bridging (needs extra feature in Cargo.toml)
313313
# class.NSNumber.bridged-to = "CoreFoundation.CFNumber.?"
314314

315+
##
316+
## Fix types
317+
##
318+
319+
# Passing NULL works, but only on later OS versions, doesn't work on e.g.
320+
# macOS 10.12 or iOS Simulator 17.2.
321+
class.NSUUID.methods."initWithUUIDBytes:".arguments.0.nullability = "nonnull"
322+
315323
###
316324
### Safety
317325
###

generated

0 commit comments

Comments
 (0)