Skip to content

NSData: Improve error handling and new initialiser#506

Merged
rfm merged 1 commit into
masterfrom
new-apis
Jun 1, 2025
Merged

NSData: Improve error handling and new initialiser#506
rfm merged 1 commit into
masterfrom
new-apis

Conversation

@hmelder
Copy link
Copy Markdown
Member

@hmelder hmelder commented May 27, 2025

Instead of printing out a warning, the underlying file reading function creates proper NSError objects, that are returned to the user.

The following initializers were implemented:
-[NSData initWithContentsOfFile:options:error:]
-[NSData initWithContentsOfURL:options:error:]
+[NSData dataWithContentsOfFile:options:error:]
+[NSData dataWithContentsOfURL:options:error:]

Additionally NSDataReadingOptions was added to NSData.h. Please note that NSDataReadingMappedIfSafe, and NSDataReadingMappedAlways currently have no effect, and need to be implemented properly.

Instead of printing out a warning, the underlying file reading function
creates proper NSError objects, that are returned to the user.

The following initializers were implemented:
-[NSData initWithContentsOfFile:options:error:]
-[NSData initWithContentsOfURL:options:error:]
+[NSData dataWithContentsOfFile:options:error:]
+[NSData dataWithContentsOfURL:options:error:]

Additionally NSDataReadingOptions was added to NSData.h.
Please note that NSDataReadingMappedIfSafe, and NSDataReadingMappedAlways
currently have no effect, and need to be implemented properly.
@hmelder hmelder requested a review from rfm as a code owner May 27, 2025 10:22
@hmelder
Copy link
Copy Markdown
Member Author

hmelder commented May 27, 2025

CI is broken in master

@rfm
Copy link
Copy Markdown
Contributor

rfm commented May 29, 2025

Basically I'm happy to merge this ... It needs trivial whitespace/style tweaks, easily done after merging. More importantly I think it should support memor mapped files (since we supported them long before Apple did), and perhaps shared memory using the new initialiser with a new constant. But those can be done after merging too.

@rfm rfm merged commit 951450c into master Jun 1, 2025
4 of 8 checks passed
@triplef triplef deleted the new-apis branch June 2, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants