1.下列输出是什么?(个人尝试bad_access。。。有人解答吗?)
NSString *text = @"info"; memset((__bridge void *)(text), 0, text.length-1); NSString *myString = [NSString stringWithFormat:@"info"]; NSLog(@"%@",myString);
2.ios c函数如何hook?(不懂)
3.写一个NSString类的实现
+ (id)initWithCString:(const char *)nullTerminatedCString encoding:(NSStringEncoding)encoding;
+ (id) stringWithCString: (const char*)nullTerminatedCString
encoding: (NSStringEncoding)encoding
{
NSString *obj;
obj = [self allocWithZone: NSDefaultMallocZone()];
obj = [obj initWithCString: nullTerminatedCString encoding: encoding];
return AUTORELEASE(obj);
}
4.oc冒泡排序
for (int i = 0; i<[arg count]; i++) for (int j=i+1; j<[arg count]; j++){ int a = [[arg objectAtIndex:i] intValue]; int b = [[arg objectAtIndex:j] intValue]; if (a > b) { [arg replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%d",b]]; [arg replaceObjectAtIndex:j withObject:[NSString stringWithFormat:@"%d",a]]; } }