Skip to content

Commit

Permalink
Add NSString::write_to_file
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Oct 28, 2022
1 parent be6c78f commit a3faaea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions objc2/CHANGELOG_FOUNDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Added `NSString::concat` and `NSString::join_path`.
* Added `CGSize`, `CGPoint` and `CGRect` (just aliases to equivalent
`NS`-types, but helps readability).
* Added `NSString::write_to_file`.

### Changed
* **BREAKING**: `NSSize::new` no longer requires it's arguments to be
Expand Down
11 changes: 10 additions & 1 deletion objc2/src/foundation/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use core::slice;
use core::str;
use std::os::raw::c_char;

use super::{NSComparisonResult, NSCopying, NSMutableCopying, NSMutableString, NSObject};
use super::{NSComparisonResult, NSCopying, NSError, NSMutableCopying, NSMutableString, NSObject};
use crate::rc::{autoreleasepool, AutoreleasePool, DefaultId, Id, Shared};
use crate::runtime::{Class, Object};
use crate::{extern_class, extern_methods, msg_send, msg_send_id, ClassType};
Expand Down Expand Up @@ -272,6 +272,15 @@ extern_methods!(

// pub fn from_nsrange(range: NSRange) -> Id<Self, Shared>
// https://developer.apple.com/documentation/foundation/1415155-nsstringfromrange?language=objc

// TODO: Safety
#[sel(writeToFile:atomically:encoding:error:)]
pub unsafe fn write_to_file(
&self,
path: &NSString,
atomically: bool,
encoding: usize,
) -> Result<(), Id<NSError, Shared>>;
}
);

Expand Down

0 comments on commit a3faaea

Please sign in to comment.