I am trying to pass a reference of an NSMutableArray from Xamarin.iOS which becomes null in Objective C layer.  

Xamarin.iOS application

NSMutableArray arraySample = new NSMutableArray();
 
IntPtr availableHandle = arraySample.Handle;
 
var result = SampleLibrary.MutableArrayTest(out arraySample);

Objective C static library

+(NSMutableArray *)arrayReturningTesting:(NSMutableArray **)prameterArray
{
    if ((prameterArray == nil) || (*prameterArray == nil))
    {
          NSLog(@"prameterArray is null");
          return nil;
    }

    NSMutableArray *arrayNumbers = [[NSMutableArray alloc]initWithObjects:@"11", @"12", nil];
    NSMutableArray *finalArray  = [[NSMutableArray alloc]init];
    [arrayNumbers addObjectsFromArray:*prameterArray];
    [finalArray addObjectsFromArray:arrayNumbers];
    NSLog(@"prameterArray is not null");

    return finalArray;
}

Output : prameterArray is null Expected output : prameterArray is not null

Is there a solution for this?

0 Answers