• 同步推笔试坑录


    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]];
                }
       }
    
    

      

  • 相关阅读:
    代理模式
    适配器模式
    策略模式
    原型模式
    内存溢出
    jvm常用参数
    单例模式
    抽象工厂
    工厂方法模式
    选择器代码
  • 原文地址:https://www.cnblogs.com/imhere/p/4342801.html
Copyright © 2020-2023  润新知