• iOS Http断点续传浅析

    iOS iOS

    http实现断点续传的关键地方就是在httprequest中加入“Range”头。

    //设置Range头,值:bytes=x-y;x:开始字节,y:结束字节,不指定则为文件末尾
    [request addValue:@"bytes …
  • Method hook

    iOS iOS
    typedef IMP *IMPPointer;
    
    BOOL class_swizzleMethodAndStore(Class class, SEL original, IMP     replacement, IMPPointer store) {  
        IMP imp = NULL;  
        Method method = class_getInstanceMethod(class, original);  
        if (method) {  
            const char *type = method_getTypeEncoding(method);  
            imp = class_replaceMethod(class, original, replacement, type);  
            if (!imp) {  
                imp = method_getImplementation(method);  
            }  
        }  
        if (imp && store) { *store = imp; }  
        return …