Objective c 将参数传递给UILabel[2]*

Objective c 将参数传递给UILabel[2]*,objective-c,xcode,arguments,uilabel,Objective C,Xcode,Arguments,Uilabel,我正在尝试从viewcontroller类调用以下(滚动动画类)类型的方法 -(void)CreateLabel:(CGRect )frame andLabel:(UILabel *[NUM_LABELS])label andview:(UIView *)view; 当我试图传递论点时,我犯了一些错误。关于如何称呼这个有什么建议吗 我就是这样叫这个方法的 ScrollAnimation *newAnimation = [[ScrollAnimation alloc] init]; [newAn

我正在尝试从viewcontroller类调用以下(滚动动画类)类型的方法

-(void)CreateLabel:(CGRect )frame andLabel:(UILabel *[NUM_LABELS])label andview:(UIView *)view;
当我试图传递论点时,我犯了一些错误。关于如何称呼这个有什么建议吗

我就是这样叫这个方法的

ScrollAnimation *newAnimation = [[ScrollAnimation alloc] init];
[newAnimation CreateLabel:CGRectMake(0, 50, 300,30) andLabel:animateLabel[NUM_LABELS] andview:self.view];
我有错误

 /Volumes/Red Drive/CarTransition/CarTransition/ViewController.m:120:66: Implicit conversion of an Objective-C pointer to 'UILabel **' is disallowed with ARC 


 /Volumes/Red Drive/CarTransition/CarTransition/ViewController.m:120:66: Incompatible pointer types sending 'UILabel *__strong' to parameter of type 'UILabel **'
创建标签方法:

  -(void)CreateLabel:(CGRect )frame andLabel:(UILabel *[NUM_LABELS])label andview:(UIView *)view{
for (int i = 0; i<NUM_LABELS ; i++){

    if(i == 0){
        label[0] = [[UILabel alloc] initWithFrame:CGRectMake(frame.origin.x, frame.origin.y, frame.size.width,frame.size.height)];
        label[i].text = @"MINI ";
    }else if(i == 1){
        label[1] = [[UILabel alloc] initWithFrame:CGRectMake(frame.origin.x, frame.origin.y - 40 ,frame.size.width, frame.size.height)];
        label[1].text = @"COOPER ";
    }else if(i == 2){
        label[2] = [[UILabel alloc] initWithFrame:CGRectMake(frame.origin.x, frame.origin.x-120 ,frame.size.width,frame.size.height)];
        label[2].text = @"STYLING";
    }
}
-(void)CreateLabel:(CGRect)frame和label:(UILabel*[NUM_LABELS])label和view:(UIView*)视图{

对于(inti=0;i,您的方法要求一个指针数组

下面是一个肮脏的例子:

- (void)passArgument:(NSObject *[])anObject total:(uint)total{
    for (int i = 0; i < total; i++) {
        NSLog(@"list --> %@", anObject[i]);
    }
}
  • 注意:对象是指针数组(*)
  • &对象[2]是指针的地址(&**)
  • 对象[1]是指向指针(**)的指针,而这不是您想要的 想要

  • 请提供定义了
    animateLabel
    的代码。
    NSString* object[5] = {@"a", @"b", @"c", @"d", @"e"};
    [self passArgument: object total: 5];
    [self passArgument: &object[2] total: 3];