If you have a C pointer which was defined in a method and are trying to return it from an object method in Objective C, what do you place as the return object type for the method?
For example, I am using code that converts a UIImage into an RGBA image map (as seen here) - but the code stores a C pointer to the memory that is unclear how to return.
- (??what goes here??) returnTextureRGB
{
// ... other code ...
void *imageData = malloc(height*width *r);
// ... other code ...
return(imageData);
}
What is the correct object type to declare being returned?
I don't know why is this related to C#, however Objective-C is a superset of C, thus every C syntax is also a valid Objective-C syntax.
Just place void*
as return type.
Well, you mention Objective-C, talk about C#... So it is not clear what exactly you are asking. For C#, you can use any type you want as long as its size is enough to store sizeof(void *)
number of bytes (which is architecture-dependent, i.e. 64 bits on 86_64 architecture) and it has the same alignment (though alignment can be worked-around). For example, ulong
will do. Objective-C transparently supports C, so just use a pointer data type as is.