Include "const void *" in "const char *"

I have a code like this:

NSData *data = [NSData dataWithContentsOfURL:objURL];
const void *buffer = [data bytes];
[self _loadData:buffer];
[data release];

The _loadData function takes an argument of the type:

- (void)_loadData:(const char *)data;

How to convert "const void" to "const char" on Objective-C?

+3
source share
2 answers

Like in C:

[self _loadData:(const char *)buffer];

must work.

+5
source

You should not release a data object because you have not explicitly allocated it. Alternatively, you can make a simple actor:

[self _loadData:(const char *) buffer];
+3
source

Source: https://habr.com/ru/post/1706675/


All Articles