Swift to Objective-C Method Call

Asked 2 years ago, Updated 2 years ago, 43 views

When calling the Objective-C method from Swift, if the argument is pointer **, how should I call it?

objective-c swift

2022-09-29 22:46

2 Answers

For example,

 - NSData initWithContentsOfURL: (NSURL*)aURL
                       options: (NSDataReadingOptions) mask
                         error: (NSError**) errorPtr]

This is

let url:NSURL=//NSURL instance
varerror: Declared as NSError?=nil//var.make optional

let data = NSData(contentsOfURL:url, options:.DataReadingMappedIfSafe, error: & error)

will look like this


2022-09-29 22:46

Apple publication Using Swift with Cocoa and Objective-C (link is Apple Developer's site with the same content).
Interacting with CAPIs → Pointers section of this e-book.

C Syntax:Type**
Swift Syntax:AutoreleasingUnsafeMutablePointer<Type>

and so on.
However, you can't tell what to do without looking at the actual program code.To be honest, I'm confused and still don't understand.


2022-09-29 22:46

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.