This is an automated email from the ASF dual-hosted git repository. GitToTheHub pushed a commit to branch pr-ios-remove-use-of-CDVPluginResult.associatedObject in repository https://gitbox.apache.org/repos/asf/cordova-plugin-file.git
commit cbfae3db73d8804944ae3ea27232ff9428027965 Author: Manuel Beck <[email protected]> AuthorDate: Fri Jul 31 22:53:53 2026 +0200 fix(ios): remove deprecated `CDVPluginResult.associatedObject` usage in `CDVFile` - replace `initWithBytesNoCopy` string creation with `initWithData:encoding:` in iOS read paths - remove `result.associatedObject = data` assignments in `readAsText` and `readAsBinaryString` - keep behavior the same while eliminating Cordova iOS 8 deprecation warnings Generated-By: GPT-5.3-Codex --- src/ios/CDVFile.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m index 59e7d64..5e40059 100644 --- a/src/ios/CDVFile.m +++ b/src/ios/CDVFile.m @@ -863,11 +863,10 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile"; [fs readFileAtURL:localURI start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) { CDVPluginResult* result = nil; if (data != nil) { - NSString* str = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSUTF8StringEncoding freeWhenDone:NO]; + NSString* str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; // Check that UTF8 conversion did not fail. if (str != nil) { result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:str]; - result.associatedObject = data; } else { errorCode = ENCODING_ERR; } @@ -962,9 +961,8 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile"; [fs readFileAtURL:localURI start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) { CDVPluginResult* result = nil; if (data != nil) { - NSString* payload = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSASCIIStringEncoding freeWhenDone:NO]; + NSString* payload = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload]; - result.associatedObject = data; } else { result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode]; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
