0

I have two question , please help .

Firstly :

how to invoke method if the method's parameters contain int[] type ?

Look this code :

- (void)tearDown {
    [self func:@[@3,@4,@5]] ; // **Error !**
    [super tearDown];
}

- (void)func:(int[])encodeFormat {

    unsigned int encodeFormatLength = sizeof(encodeFormat) / sizeof(int) ;
        for( unsigned int index = 0 ; index < encodeFormatLength ; index++ ) {
            int value = encodeFormat[index] ;
            printf("%d\n",value) ;
        }
}

Secondly :

how to solve the Xcode's warning message ?

Look this code :

- (void)func:(int[])encodeFormat {

    // Warning : 
    // Sizeof on array function parameter will return sizeof 'int *' instead of 'int []'
    unsigned int encodeFormatLength = sizeof(encodeFormat) / sizeof(int) ;
}
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
user5465320
  • 719
  • 2
  • 7
  • 15

0 Answers0