Skip to content

Commit

Permalink
nsuiLayoutManager property
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Apr 4, 2024
1 parent a85407c commit e447d19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ public protocol NSUIViewControllerRepresentable: UIViewControllerRepresentable {

## Cross-Platform Wrappers

There are cases where it is necessary to provide cross-platform wrappers around functions, acessors, or initializers.
There are cases where it is necessary to provide cross-platform wrappers around functions, accessors, or initializers.

```swift
// SwiftUI
Color(nsuiColor: NSUIColor)
Image(nsuiImage: NSUIImage)

// AppKit/UIKit
NSUITextView.nsuiLayoutManager
```

## Conventions
Expand Down Expand Up @@ -122,7 +126,7 @@ If you need to enhance `NSUI`, follow the following guidelines:

1. Check if the type you need is defined in the `Aliases.swift` file.
2. If your type needs to bridging functions, define them in a dedicated file.
3. Prioritize `UIKit` implemenations, unless type-mismatches prevent it.
3. Prioritize `UIKit` implementations, unless type-mismatches prevent it.

## Alternatives

Expand Down
9 changes: 9 additions & 0 deletions Sources/NSUI/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ import UIKit
public typealias NSUITextStorageEditActions = NSTextStorage.EditActions

#endif

extension NSUITextView {
/// NSUI wrapper around `layoutManager` property.
///
/// This value can be nil on macOS.
public var nsuiLayoutManager: NSLayoutManager? {
layoutManager
}
}

0 comments on commit e447d19

Please sign in to comment.