- 回答person的retainCount值,并解释为什么
Person * per = [[Person alloc] init];
self.person = per;
@implementation Person
-(void)setAge:(int)newAge {
self.age = newAge;
}
@end
for (int i = 0; i < someLargeNumber; i++) {
NSString *string = @”Abc”;
string = [string lowercaseString];
string = [string stringByAppendingString:@"xyz"];
NSLog(@“%@”, string);
}
NSLog(@"%@",[string componentsSeparatedByString:@“|"][0]);
NSLog(@"%@",[string componentsSeparatedByString:@“|"][1]);
5 用obj-c写一个冒泡排序
NSMutableArray *array = [NSMutableArray arrayWithObject:@“15”,@“12”,@“5”,@“8”,nil];
for(int i = 0;i < array.count-1; i++){
int a = [array[i] intValue];
for(int j = i+1; j<array.count; j++ ){
int b = [array [j] intValue];
if(a < b){
[array exchangeObjetAtIndex:i withObjectAtIndex:j];
}
}
}
for(int i = 0;i < array.count;i++){
NSLog(@“%@“,array[i]);
}