零碎知识点

手机序列号
NSString* identifierNumber = [[UIDevice currentDevice] uniqueIdentifier];  
NSLog(@"手机序列号: %@",identifierNumber);  
手机别名: 用户定义的名称
NSString* userPhoneName = [[UIDevice currentDevice] name];  
NSLog(@"手机别名: %@", userPhoneName);  
设备名称
NSString* deviceName = [[UIDevice currentDevice] systemName];  
NSLog(@"设备名称: %@",deviceName );  
手机系统版本
NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];  
NSLog(@"手机系统版本: %@", phoneVersion);  
手机型号
NSString* phoneModel = [[UIDevice currentDevice] model];  
NSLog(@"手机型号: %@",phoneModel );  
地方型号 (国际化区域名称)
NSString* localPhoneModel = [[UIDevice currentDevice] localizedModel];  
NSLog(@"国际化区域名称: %@",localPhoneModel );  
当前应用名称
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];  
NSString *appCurName = [infoDictionary objectForKey:@"CFBundleDisplayName"];  
NSLog(@"当前应用名称:%@",appCurName);  
当前应用软件版本 比如:1.0.1
NSString *appCurVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];  
NSLog(@"当前应用软件版本:%@",appCurVersion);  
当前应用版本号码 int类型
NSString *appCurVersionNum = [infoDictionary objectForKey:@"CFBundleVersion"];  
NSLog(@"当前应用版本号码:%@",appCurVersionNum);  
越狱检测:
- (int)getenv
{
    //以下检测的过程是越往下,越狱越高级
    
    //    /Applications/Cydia.app, /privte/var/stash
    int jailbroken = -99999;
    NSString *cydiaPath = @"/Applications/Cydia.app";
    NSString *aptPath = @"/private/var/lib/apt/";
    if ([[NSFileManager defaultManager] fileExistsAtPath:cydiaPath]) {
        jailbroken = 111;
    }
    if ([[NSFileManager defaultManager] fileExistsAtPath:aptPath]) {
        jailbroken = 222;
    }
    
    //可能存在hook了NSFileManager方法,此处用底层C stat去检测
    struct stat stat_info;
    if (0 == stat("/Library/MobileSubstrate/MobileSubstrate.dylib", &stat_info)) {
        jailbroken = 333;
    }
    if (0 == stat("/Applications/Cydia.app", &stat_info)) {
        jailbroken = 444;
    }
    if (0 == stat("/var/lib/cydia/", &stat_info)) {
        jailbroken = 555;
    }
    if (0 == stat("/var/cache/apt", &stat_info)) {
        jailbroken = 666;
    }

    //可能存在stat也被hook了,可以看stat是不是出自系统库,有没有被攻击者换掉,这种情况的可能性很小
    int ret;
    Dl_info dylib_info;
    int (*func_stat)(const char *,struct stat *) = stat;
    if ((ret = dladdr(func_stat, &dylib_info))) {
        NSLog(@"lib:%s",dylib_info.dli_fname);      //如果不是系统库,肯定被攻击了
        if (strcmp(dylib_info.dli_fname, "/usr/lib/system/libsystem_kernel.dylib")) {   //不相等,肯定被攻击了,相等为0
            jailbroken = 777;
        }
    }
    
### // 此方法存在appStore审核不通过的情况:
    //检测链接动态库,看下是否被链接了异常动态库
    //通常,越狱机的输出结果会包含字符串: Library/MobileSubstrate/MobileSubstrate.dylib——之所以用检测链接动态库的方法,是可能存在前面的方法被hook的情况。这个字符串,前面的stat已经做了  
      
    //如果攻击者给MobileSubstrate改名,但是原理都是通过DYLD_INSERT_LIBRARIES注入动态库  
    //那么可以,检测当前程序运行的环境变量  
    charchar *env = getenv("DYLD_INSERT_LIBRARIES");  
    if (env != NULL) {  
        jailbroken = YES;  
    }  

    return jailbroken;
}
注释和标记的几种方式:
/*! 按钮1 */
@property(nonatomic,strong)UIButton * btn1;

/** 按钮2 */
@property(nonatomic,strong)UIButton * btn2;

/// 按钮3
@property(nonatomic,strong)UIButton * btn3;

@property(nonatomic,strong)UIButton * btn4;/**< 按钮4 */

//按钮5 (快捷键 cmd + /)
@property(nonatomic,strong)UIButton * btn5;

/* 按钮6 */
@property(nonatomic,strong)UIButton * btn6;

前面4种加了特效,可以显示出自己给属性、方法、成员变量等添加上去的描述。后面2种,则不可以。

标记

6种主流标记

// MARK: ~~~~~~~~~~~~~~~~~~~~
// TODO: puti is not a tree
// FIXME: mirror is not a table
// !!!: it is empty at all here
// ???: why pm 2.5 is so high
#pragma mark - UITableViewDelegate (中间的 ‘-’ 号,可以添加一条分割线)

2种非主流标记:
#warning >>>>>>>>>>>>>>
#error <<<<<<<<<<<<<<

链接:https://www.jianshu.com/p/ba4ecbdfe0e3

你可能感兴趣的:(零碎知识点)