- iOS-OC对象— isa指针分析探究
一眼万年的星空
前言:isa是个很神奇的、很强大的、很低调的角色,她风里来雨里去,在iOS开发的过程中曾经多少次出现在我们的世界里,悄无声息、无怨无悔的为我们提供各种各样的服务!假如你知道NSObject,那么你就一定要知道isa,可以说,她是一个对象的灵魂,如果没有她,一切都将失去了颜色......一、从对象的alloc探索isaPS:友情链接《OC对象原理探究(上)——对象的alloc》《OC对象原理探究(下
- iOS-OC底层10:dyld加载流程分析
MonKey_Money
前沿我们实现ViewController的+(void)load方法,在main函数中添加c++方法//ViewController的load方法+(void)load{NSLog(@"%s",__func__);}//程序入口intmain(intargc,char*argv[]){NSString*appDelegateClassName;NSLog(@"1223333");@autorele
- iOS-OC底层21:GCD 函数 和队列
MonKey_Money
GCD简介1.什么是GCD?全称是GrandCentralDispatch,将任务添加到队列,并且指定执行任务的函数纯C语言,提供了非常多强大的函数.2.GCD的优势GCD是苹果公司为多核的并行运算提出的解决方案GCD会自动利用更多的CPU内核(比如双核、四核)GCD会自动管理线程的生命周期(创建线程、调度任务、销毁线程)程序员只需要告诉GCD想要执行什么任务,不需要编写任何线程管理代码函数任务使
- iOS-OC底层Method-swizzling的那些坑
泽泽伐木类
前言关于Method-swizzling,对于iOS开发者来讲并不陌生,且应用自如。今天我们主要整理一下关于Method-swizzling使用时的一些注意事项,从而避免采坑。开始准备工作:创建ZZPerson类,创建ZZStudent类(继承自ZZPerson),创建ZZStudent+Swizzling.h分类ZZPerson@interfaceZZPerson:NSObject-(void)
- iOS-OC底层四:类的属性、方法和协议
轰天裂天罗三炮
一、对象、ISA、类、元类、根元类间的关系核心知识点:类声明对象,给对象分配多少内存是依据类,对象的ISA指向类对象在内存中第一个8字节储存的是ISAISA中的shiftClass段就是类,即类为对象的isa&mask类也是一种对象,objc_class继承自objc_object,类的第一个8字节也是ISA,所以万物皆对象,万物皆有isa类的ISA中的shiftClass为元类,即元类为类的is
- iOS-OC底层-RunLoop
泽泽伐木类
前言RunLoop,又一个面试常常被问到的东西,它是什么?一个运行循环,用来处理App中的各种任务,当有任务的时候,执行任务,没任务的时候进入休眠;每一个线程对应一个Runloop,主线程的RunLoop默认是开启的,子线程的需要手动开启;每一个Runloop下对应多个Modes,每一个Mode下又有多个Items事务.........这些在面试的时候基本上都能答得上来,但我也相信大部分人都只是停
- iOS-OC底层-AutoReleasePool分析
泽泽伐木类
概念autoreleasepool,即自动释放池。在aotureleasepool中创建的对象,会将对象添加到当前的aotureleasepool中,当自动释放池销毁时,对所有的对象做release操作。那具体是个什么样的操作流程呐?我们开始今天的探索。开始先上一段代码片段:intmain(intargc,constchar*argv[]){@autoreleasepool{//insertcod
- iOS-OC底层19:内存五大区域
MonKey_Money
栈由编译器自动分配并释放,存放函数的参数值,局部变量等。栈是系统数据结构,对应线程/进程是唯一的。栈是向低地址扩展的数据结构,是连续的内存区域,采用后进先出(LIFO)。优缺点:快速高效缺点有限制,数据不灵活[LIFO]iOS主线程栈大小是1MB其他线程是512KBMAC是8M堆由程序员分配和释放,若程序员不释放,程序结束时可能由系统回收。堆是向高地址扩展的数据结构,是不连续的内存区域,以链表的方
- iOS-OC启动优化
大橘猪猪侠
应用启动分为冷启动和热启动;冷启动指:在内存中不包含相关数据,必须从磁盘载入到内存中。热启动指:在打开应用程序时,在内存中存在部分程序数据,使得程序数据不用全部载入磁盘。测试app启动分两个阶段,由main函数作为一个分界点,main之前时pre-main,系统反馈。main函数之后是靠自己业务去进行优化,而启动优化,主要解决main函数之前。通过在editscheme中添加环境变量DYLD_PR
- iOS-OC、Swift混编之桥接文件
码渣
前言:想必大家都有这样的烦恼:用OC开发想导入Swift文件,用Swift开发想导入OC文件,那么有什么办法呢,那好,我们可以利用桥接文件来实现新建一个OC工程,然后创建继续于NSObject的Swift类Snip20180830_41.png这时会提示你是否添加桥接文件,点击创建系统会自动创建一个桥接文件,否则需要自己手动创建新建Swift类手动创建桥接文件首先创建.h名称,名字最好是xxx-B
- iOS-OC对象原理_内存布局
泽泽伐木类
前言本文是基于objc-781源码进行分析探索实例对象与类对象底层结构,isa信息分布拓补图.001.jpeg在objc-runtime-new.h中,structobjc_class:objc_object{//ClassISA;Classsuperclass;cache_tcache;//formerlycachepointerandvtableclass_data_bits_tbits;//
- iOS-OC底层三:ISA的本质
轰天裂天罗三炮
1.前言对象在计算机中的存储是无序的,内存中的一段地址空间,有可能表示A类声明的对象,也可能是B类声明的对象。我们根据一个对象,可以找到对象所在的地址空间,在计算机硬盘中,地址空间存储的是0和1。但是计算机是怎么知道0和1所代表的含义?为什么可以根据对象找到自己的属性和方法,还可以找到父类的属性和方法,这就是isa的作用。我们自定义了一个Person类,没有任何属性和方法,为什么我们可以调用all
- iOS-OC对象原理_alloc&init
泽泽伐木类
alloc&init探索-(void)viewDidLoad{[superviewDidLoad];//熟悉的入手-对象//alloc做了什么//init做了什么ZZPerson*p1=[ZZPersonalloc];ZZPerson*p2=[p1init];ZZPerson*p3=[p1init];ZZNSLog(@"%@-%p-%p",p1,p1,&p1);ZZNSLog(@"%@-%p-%p
- iOS-OC底层-block分析
泽泽伐木类
前言block的类型从一段代码开始//全局变量n,namestaticintn=100;staticNSString*name=@"zezefamily";-(void)demo10{//0.没有引用外部变量的testBlock0void(^testBlock0)(BOOLok);testBlock0=^(BOOLok){};NSLog(@"testBlock0==%@",testBlock0);
- iOS-OC底层一:对象alloc的本质
轰天裂天罗三炮
1.准备源码程序源码分析alloc&init&new的流程,使用从github上下载的LGCooci的源码https://github.com/LGCooci/KCCbjc4_debug。因为设备限制,我是基于818的源码进行学习。从github下载完成后,在KCObjcBuild所在的目录新建一个OC类命名为Person,Person类中什么都不写。在main.m中写入如下代码:#import"
- iOS-内存管理
泽泽伐木类
前言说到iOS的内存管理,大致应该分为以下几个方面:NSTaggedPointer类型alloc,retain,release,dealloc,retainCount原理@autoreleasepool原理alloc可以移步我的这篇文章:iOS-OC对象原理_alloc&init@autoreleasepool移步:iOS-OC底层-AutoReleasePool分析TaggedPointerTa
- iOS-OC底层二 :对象内存对齐
轰天裂天罗三炮
一、内存对齐获取内存大小的三种方式分别是:sizeof:sizeof计算内存大小时,传入的主要对象是数据类型,这个在编译器的编译阶段(即编译时)就会确定大小而不是在运行时确定。最终得到的结果是该数据类型占用空间的大小。class_getInstanceSize:用于获取类的实例对象所占用的内存大小,并返回具体的字节数,其本质就是获取实例对象中成员变量的内存大小malloc_size:这个函数是获取
- iOS-OC运行时
Alan龙马
https://www.jianshu.com/p/c2f382941a0bhttps://blog.csdn.net/u011342466/article/details/50803075方法置换https://blog.csdn.net/u011604049/article/details/54972504
- iOS-OC底层08:objc_msgSend慢速查找
MonKey_Money
前沿在objc_msgSend缓存中读取IMP中,如果缓存没有找到会有下面方法.macroCheckMiss//missifbucket->sel==0.if$0==GETIMPcbzp9,LGetImpMiss.elseif$0==NORMALcbzp9,__objc_msgSend_uncached.elseif$0==LOOKUPcbzp9,__objc_msgLookup_uncached
- iOS-OC底层25:LLVM和自定义LLVM插件
MonKey_Money
1.概念1.LLVMLLVM是架构编译器(compiler)的框架系统,以c++编写而成,用于优化以任意程序语言编写的程序的编译事件(complie-time),链接时间(link-time),运行时间(run-time),以及空闲时间(idle-time),对开发者保持开放,并兼容以有脚本。LLVM计划启动于2000年,最初由美国UIUC大学的ChrisLattner博士主持开展。2006Chr
- iOS-OC底层15:面试题
MonKey_Money
1.我们关联的对象是否需要手动移除,为什么不需要手动移除,在对象的dealloc中在关联对象时,如果是第一次,我们会设置对象的has_assoc为true,看dealloc代码-(void)dealloc{_objc_rootDealloc(self);}inlinevoidobjc_object::rootDealloc(){if(isTaggedPointer())return;//fixme
- iOS-OC启动优化:clang插桩实现二进制重排
MonKey_Money
1.概念1.1.测量Pre-mainTime在工程的scheme中添加环境变量DYLD_PRINT_STATISTICS,看main之前的时间消耗image.png打印日志Totalpre-maintime:1.5seconds(100.0%)dylibloadingtime:313.91milliseconds(20.1%)rebase/bindingtime:123.22millisecond
- iOS-OC底层09:动态方法决议 & 消息转发
MonKey_Money
前沿我们在oc层面调用对象方法实质是向某对象发送消息也就是objc_msgSend,objc_msgSend需要找到对应方法的实现也就是函数指针IMP,查找IMP首先在缓存中查找也就是快速查找,然后慢速查找也就是在类的方法类表中查找,如果这两种方法都找不到IMP,则在源码中有lookUpImpOrForward,可以看到会走resolveMethod_locked函数也就是动态方法决议动态方法决议
- iOS-OC自动引用计数(内存管理)
JerryLMJ
前言自动引用计数是指内存管理中对引用采取自动计数的技术。OC中ARC模式是让编译器来替我们实现内存管理,我们无需再像在MRC模式下需要手动键入retain、release来进行内存管理,不但降低了程序的出错概率也减少了程序的书写工作量。这里要提一下的是,拥有ARC这样强大内存管理模式主要依赖于3.0及以上版本的LLVM编译器。内存管理OC内存管理的核心就是引用计数。我们以遛狗的场景为例来解释引用计
- iOS-OC block详解
洧中苇_4187
block的本质的就是一段代码块,也是一个OC对象,它在合适的时间进行调用,它最终继承自NSObject,验证如下:staticintage=10;void(^block)(void)=^(){NSLog(@"这是一个block%d",age);};block();NSLog(@"-------%@--------",[blockclass]);NSLog(@"-------%@--------"
- iOS小项目之第二弹- 别踩白块
ManoBoo
iOS-OC项目别踩白块(Don'tTapTheWhiteTile)写在前面的话①别踩白块游戏简介:《别踩白块儿Don'tTapTheWhiteTile》,这就是这个游戏唯一的一个规则,我们只需要不断踩着黑色方块前进即可,很简单吧?谁都可以会玩,但并不是谁都能玩得很好噢,你呢?快来挑战看看吧!经典模式,以最快的速度到达终点。街机模式,你有能力得多少分就得多少分,没有任何限制,这也是最具挑战性的一个
- iOS-OC实现LRU算法NSDictionary容器(非线程安全)
vinnyxiong
1LRU算法LRU(Leastrecentlyused,最近最少使用)算法根据数据的历史访问记录来进行淘汰数据,其核心思想是“如果数据最近被访问过,那么将来被访问的几率也更高”。这篇文章对LRU缓存算法做了非常详细的介绍:缓存淘汰算法之LRU-OYK可惜Foundation框架中并未提供一个比较简洁的LRU算法,NSCache没怎么看懂,java中有LruCache。2使用NSDictionary
- iOS-OC底层28:autoreleasepool自动释放池
MonKey_Money
1.探究autoreleasepool是什么东西1.clang探究autoreleasepool本质intmain(intargc,constchar*argv[]){@autoreleasepool{//insertcodehere...NSLog(@"Hello,World!");}return0;}clang-rewrite-objcmain.m-omain.cppclang之后的代码int
- iOS-OC底层24:Block底层原理
MonKey_Money
1.Block的类型全局Block(NSGlobalBlock)void(^block)(void)=^{NSLog(@"------");};NSLog(@"%@",block);//打印结果block内部没有引用外部变量的Block类型都是NSGlobalBlock类型,存储于全局数据区,由系统管理其内存,retain、copy、release操作都无效。如果只引用全局变量和静态变量也是全局B
- iOS-OC底层-@synchronized分析
泽泽伐木类
前言锁,在我们的iOS开发中还是经常用到的,特别是在一些多线程的安全访问方面提供了提供了便捷的方案。锁,分为自旋锁,互斥锁,读写锁等类型。在iOS下,我们常见的锁包括:@synchronized,NSLock,dispatch_semphore,NSCondition,NSConditionLock,NSRecursiveLock等。本篇文章我们就重点分析下@synchronized的本质。开始首
- jdk tomcat 环境变量配置
Array_06
javajdktomcat
Win7 下如何配置java环境变量
1。准备jdk包,win7系统,tomcat安装包(均上网下载即可)
2。进行对jdk的安装,尽量为默认路径(但要记住啊!!以防以后配置用。。。)
3。分别配置高级环境变量。
电脑-->右击属性-->高级环境变量-->环境变量。
分别配置 :
path
&nbs
- Spring调SDK包报java.lang.NoSuchFieldError错误
bijian1013
javaspring
在工作中调另一个系统的SDK包,出现如下java.lang.NoSuchFieldError错误。
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.l
- LeetCode[位运算] - #136 数组中的单一数
Cwind
java题解位运算LeetCodeAlgorithm
原题链接:#136 Single Number
要求:
给定一个整型数组,其中除了一个元素之外,每个元素都出现两次。找出这个元素
注意:算法的时间复杂度应为O(n),最好不使用额外的内存空间
难度:中等
分析:
题目限定了线性的时间复杂度,同时不使用额外的空间,即要求只遍历数组一遍得出结果。由于异或运算 n XOR n = 0, n XOR 0 = n,故将数组中的每个元素进
- qq登陆界面开发
15700786134
qq
今天我们来开发一个qq登陆界面,首先写一个界面程序,一个界面首先是一个Frame对象,即是一个窗体。然后在这个窗体上放置其他组件。代码如下:
public class First { public void initul(){ jf=ne
- Linux的程序包管理器RPM
被触发
linux
在早期我们使用源代码的方式来安装软件时,都需要先把源程序代码编译成可执行的二进制安装程序,然后进行安装。这就意味着每次安装软件都需要经过预处理-->编译-->汇编-->链接-->生成安装文件--> 安装,这个复杂而艰辛的过程。为简化安装步骤,便于广大用户的安装部署程序,程序提供商就在特定的系统上面编译好相关程序的安装文件并进行打包,提供给大家下载,我们只需要根据自己的
- socket通信遇到EOFException
肆无忌惮_
EOFException
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:
- 基于spring的web项目定时操作
知了ing
javaWeb
废话不多说,直接上代码,很简单 配置一下项目启动就行
1,web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="h
- 树形结构的数据库表Schema设计
矮蛋蛋
schema
原文地址:
http://blog.csdn.net/MONKEY_D_MENG/article/details/6647488
程序设计过程中,我们常常用树形结构来表征某些数据的关联关系,如企业上下级部门、栏目结构、商品分类等等,通常而言,这些树状结构需要借助于数据库完成持久化。然而目前的各种基于关系的数据库,都是以二维表的形式记录存储数据信息,
- maven将jar包和源码一起打包到本地仓库
alleni123
maven
http://stackoverflow.com/questions/4031987/how-to-upload-sources-to-local-maven-repository
<project>
...
<build>
<plugins>
<plugin>
<groupI
- java IO操作 与 File 获取文件或文件夹的大小,可读,等属性!!!
百合不是茶
类 File
File是指文件和目录路径名的抽象表示形式。
1,何为文件:
标准文件(txt doc mp3...)
目录文件(文件夹)
虚拟内存文件
2,File类中有可以创建文件的 createNewFile()方法,在创建新文件的时候需要try{} catch(){}因为可能会抛出异常;也有可以判断文件是否是一个标准文件的方法isFile();这些防抖都
- Spring注入有继承关系的类(2)
bijian1013
javaspring
被注入类的父类有相应的属性,Spring可以直接注入相应的属性,如下所例:1.AClass类
package com.bijian.spring.test4;
public class AClass {
private String a;
private String b;
public String getA() {
retu
- 30岁转型期你能否成为成功人士
bijian1013
成长励志
很多人由于年轻时走了弯路,到了30岁一事无成,这样的例子大有人在。但同样也有一些人,整个职业生涯都发展得很优秀,到了30岁已经成为职场的精英阶层。由于做猎头的原因,我们接触很多30岁左右的经理人,发现他们在职业发展道路上往往有很多致命的问题。在30岁之前,他们的职业生涯表现很优秀,但从30岁到40岁这一段,很多人
- 【Velocity四】Velocity与Java互操作
bit1129
velocity
Velocity出现的目的用于简化基于MVC的web应用开发,用于替代JSP标签技术,那么Velocity如何访问Java代码.本篇继续以Velocity三http://bit1129.iteye.com/blog/2106142中的例子为基础,
POJO
package com.tom.servlets;
public
- 【Hive十一】Hive数据倾斜优化
bit1129
hive
什么是Hive数据倾斜问题
操作:join,group by,count distinct
现象:任务进度长时间维持在99%(或100%),查看任务监控页面,发现只有少量(1个或几个)reduce子任务未完成;查看未完成的子任务,可以看到本地读写数据量积累非常大,通常超过10GB可以认定为发生数据倾斜。
原因:key分布不均匀
倾斜度衡量:平均记录数超过50w且
- 在nginx中集成lua脚本:添加自定义Http头,封IP等
ronin47
nginx lua csrf
Lua是一个可以嵌入到Nginx配置文件中的动态脚本语言,从而可以在Nginx请求处理的任何阶段执行各种Lua代码。刚开始我们只是用Lua 把请求路由到后端服务器,但是它对我们架构的作用超出了我们的预期。下面就讲讲我们所做的工作。 强制搜索引擎只索引mixlr.com
Google把子域名当作完全独立的网站,我们不希望爬虫抓取子域名的页面,降低我们的Page rank。
location /{
- java-3.求子数组的最大和
bylijinnan
java
package beautyOfCoding;
public class MaxSubArraySum {
/**
* 3.求子数组的最大和
题目描述:
输入一个整形数组,数组里有正数也有负数。
数组中连续的一个或多个整数组成一个子数组,每个子数组都有一个和。
求所有子数组的和的最大值。要求时间复杂度为O(n)。
例如输入的数组为1, -2, 3, 10, -4,
- Netty源码学习-FileRegion
bylijinnan
javanetty
今天看org.jboss.netty.example.http.file.HttpStaticFileServerHandler.java
可以直接往channel里面写入一个FileRegion对象,而不需要相应的encoder:
//pipeline(没有诸如“FileRegionEncoder”的handler):
public ChannelPipeline ge
- 使用ZeroClipboard解决跨浏览器复制到剪贴板的问题
cngolon
跨浏览器复制到粘贴板Zero Clipboard
Zero Clipboard的实现原理
Zero Clipboard 利用透明的Flash让其漂浮在复制按钮之上,这样其实点击的不是按钮而是 Flash ,这样将需要的内容传入Flash,再通过Flash的复制功能把传入的内容复制到剪贴板。
Zero Clipboard的安装方法
首先需要下载 Zero Clipboard的压缩包,解压后把文件夹中两个文件:ZeroClipboard.js
- 单例模式
cuishikuan
单例模式
第一种(懒汉,线程不安全):
public class Singleton { 2 private static Singleton instance; 3 pri
- spring+websocket的使用
dalan_123
一、spring配置文件
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.or
- 细节问题:ZEROFILL的用法范围。
dcj3sjt126com
mysql
1、zerofill把月份中的一位数字比如1,2,3等加前导0
mysql> CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL, -> day
- Android开发10——Activity的跳转与传值
dcj3sjt126com
Android开发
Activity跳转与传值,主要是通过Intent类,Intent的作用是激活组件和附带数据。
一、Activity跳转
方法一Intent intent = new Intent(A.this, B.class); startActivity(intent)
方法二Intent intent = new Intent();intent.setCla
- jdbc 得到表结构、主键
eksliang
jdbc 得到表结构、主键
转自博客:http://blog.csdn.net/ocean1010/article/details/7266042
假设有个con DatabaseMetaData dbmd = con.getMetaData(); rs = dbmd.getColumns(con.getCatalog(), schema, tableName, null); rs.getSt
- Android 应用程序开关GPS
gqdy365
android
要在应用程序中操作GPS开关需要权限:
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
但在配置文件中添加此权限之后会报错,无法再eclipse里面正常编译,怎么办?
1、方法一:将项目放到Android源码中编译;
2、方法二:网上有人说cl
- Windows上调试MapReduce
zhiquanliu
mapreduce
1.下载hadoop2x-eclipse-plugin https://github.com/winghc/hadoop2x-eclipse-plugin.git 把 hadoop2.6.0-eclipse-plugin.jar 放到eclipse plugin 目录中。 2.下载 hadoop2.6_x64_.zip http://dl.iteye.com/topics/download/d2b
- 如何看待一些知名博客推广软文的行为?
justjavac
博客
本文来自我在知乎上的一个回答:http://www.zhihu.com/question/23431810/answer/24588621
互联网上的两种典型心态:
当初求种像条狗,如今撸完嫌人丑
当初搜贴像条犬,如今读完嫌人软
你为啥感觉不舒服呢?
难道非得要作者把自己的劳动成果免费给你用,你才舒服?
就如同 Google 关闭了 Gooled Reader,那是
- sql优化总结
macroli
sql
为了是自己对sql优化有更好的原则性,在这里做一下总结,个人原则如有不对请多多指教。谢谢!
要知道一个简单的sql语句执行效率,就要有查看方式,一遍更好的进行优化。
一、简单的统计语句执行时间
declare @d datetime ---定义一个datetime的变量set @d=getdate() ---获取查询语句开始前的时间select user_id
- Linux Oracle中常遇到的一些问题及命令总结
超声波
oraclelinux
1.linux更改主机名
(1)#hostname oracledb 临时修改主机名
(2) vi /etc/sysconfig/network 修改hostname
(3) vi /etc/hosts 修改IP对应的主机名
2.linux重启oracle实例及监听的各种方法
(注意操作的顺序应该是先监听,后数据库实例)
&nbs
- hive函数大全及使用示例
superlxw1234
hadoophive函数
具体说明及示例参 见附件文档。
文档目录:
目录
一、关系运算: 4
1. 等值比较: = 4
2. 不等值比较: <> 4
3. 小于比较: < 4
4. 小于等于比较: <= 4
5. 大于比较: > 5
6. 大于等于比较: >= 5
7. 空值判断: IS NULL 5
- Spring 4.2新特性-使用@Order调整配置类加载顺序
wiselyman
spring 4
4.1 @Order
Spring 4.2 利用@Order控制配置类的加载顺序
4.2 演示
两个演示bean
package com.wisely.spring4_2.order;
public class Demo1Service {
}
package com.wisely.spring4_2.order;
public class