我怎么能在 Objective - C 中编写一个函数,它获取 3 个参数并且在第一个参数中存储第二个和第三个参数的总和?

How could i write a function in Objective - C which gets 3 parameters and in the first parameter is stored the sum of the 2nd and 3rd parameter?

我是 Objective C 编程新手,我想知道解决此练习的 steps/approach。

-(void)addingSumInto:(NSInteger *)sum byAddingValue:(NSInteger)integerOne andValue:(NSInteger)integerTwo{

    //Here you can Do with these three parameters.
    //As your question is unclear so lets add above three and then simply return them


   *sum = integerOne + integerTwo;

}

现在在你的主方法调用上面这样的方法..

NSInteger sum;
[self addingSumInto:&sum byAddingValue:99 andValue:155];
NSLog(@"%ld",sum);
-(void)myValue:(int *) sum istheSumOfFirst:(int)a andSecond:(int)b {
    *sum = a + b;
}

你可以像这样调用函数

int sum;
[self myValue:&sum istheSumOfFirst:5 andSecond:3];
NSLog(@"%i", sum);

主机:$8