I begin to learn an Objective-C after 5 years of experience in Java and don't understand some of it's constructions. What does this Some_Object** mean? For example in the method definition here:
- (NSString *)checkLastUpdate:(NSUInteger)loggedId
returnMsgs:(NSMutableArray **)returnMsgs
{
....
if (returnMsgs)
{
*returnMsgs = NewMsgs;
}
}
It is pointer to pointer or what? And what it is the reason of using this?
It's Pointer-to-pointer type, the same thing in C language.
I don't think it is a good behavior except for error callback. For example, we call one function and need error info in case that the function failed:
- (id)handleData:(NSData *)inData error:(NSError **)outError;
{
if (inData == NULL || [inData length] == 0)
{
if (outError)
*outError = [NSError errorWithDomain:kDataErrorDomain code:-1 userInfo:NULL];
We can call like this :
NSError *error = NULL;
[self handleData:data error:&error];
if (error) {
// Handle error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With