我有两个功能,我应该使用哪一个?请解释一下差异.
A:
- (NSMutableArray *)FunctionA:(int)count {
NSMutableArray *a = [[NSMutableArray alloc] init];
for (int i = 0; i < count; i++) {
[a addObject:[NSNumber numberWithInt:0] ];
}
return [a autorelease];
}
Run Code Online (Sandbox Code Playgroud)
B:
-(NSMutableArray *)FunctionB:(int)count {
NSMutableArray *b = [NSMutableArray arrayWithCapacity:count];
for (int i=0;i<count; i++){
[b addObject:[NSNumber numberWithInt:0] ];
}
return b; // or [b autorelease] ?
}
Run Code Online (Sandbox Code Playgroud) 我想知道如何格式化浮点数.
Float Want to display
1.0 1
1.52 1.5
1.58 1.6
Run Code Online (Sandbox Code Playgroud) 下面的代码是一个简单的c#函数返回一个int数组.我想知道如何将其转换为Objective-C
private int[] test()
{
int[] a = new int[2];
a[0] = 1;
a[1] = 2;
return a;
}
Run Code Online (Sandbox Code Playgroud) 我向UIScrollView添加了10个按钮
for (int i=0; i<10; i++) {
UIButton *btn = ....
[ScrollView addSubview:btn];
}
Run Code Online (Sandbox Code Playgroud)
我怎么能参考每个按钮?