Felix's Space

Never send to know for whom the bells tolls; it tolls for thee.

When you are old

poem

Another year,so many things changed,so many people left,I don’t know what to do,but carry on and on.

Viva la vida!

        When you are old and grey and full of sleep
     And nodding by the fire,take down this book
     And slowly read,and dream of the soft look
     Your eyes had once, and of their shadows deep;
    
     How many loved your moments of glad grace,
     And loved your beauty with love false or true,
     But one man loved the pilgrim soul in you,
     And loved the sorrows of your changing face;
    
     And bending down beside the glowing bars,
     Murmur,a little sadly,how love fled
     And paced upon the mountains overhead
     And hid his face amid a crowd of stars.
  
  (BY William Butler Yeats)

1 Jan 2015 #poem

iOS 截屏拼图

iOS

1. 普通界面

ios 7 以后截图

ios7中添加了调用 snapshotViewAfterScreenUpdates 创建一个复合视图的快照。然后返回一个uiview对象来表示调用视图的整体外观。

Supplying YES for -snapshotViewAfterScreenUpdates: means it needs a trip back to the runloop to actually draw the image. If you supply NO, it will try immediately, but if your view is off screen or otherwise hasn’t yet drawn to the screen, the snapshot will be empty.

因为返回的是一个view对象,所以,你可以更改它以及它的layer属性.但是呢,你不能够修改它的layer的content属性;如果你试图这么做,将不会有任何效果.如果当前的view还没有渲染,或者这么说吧,因为还没有出现在屏幕上,那么,这个截取的view将不会有能显示的content.

如果你想要加载一个图形效果,比如blur,请使用这个方法 drawViewHierarchyInRect:afterScreenUpdates: 来代替.

22 Dec 2014 #iOS #snapshot

多线程 NSOperation

iOS

NSOperation介绍

NSOperation是一个抽象的基类,表示一个独立的计算单元,可以为子类提供有用且线程安全的建立状态,优先级,依赖和取消等操作。系统已经给我们封装了NSBlockOperation和NSInvocationOperation这两个实体类。

  1. 使用NSOperation处理多线程时,就是将“操作”添加到队列中。
  2. NSOperation是一个抽象类,不能直接使用(方法没有实现),约束子类都具有共同的属性和方法。
  3. NSOperation的子类:NSInvocationOperation、NSBlockOperation、自定义NSOperation。
  4. 通过NSOperationQueue可以创建并发队列,获取主队列,获取当前队列。

17 Nov 2014 #iOS #NSOperation

SQLite(简介)

Database

SQLite是一个进程内的库,实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。它是一个零配置的数据库,这意味着与其他数据库一样,您不需要在系统中配置。 就像其他数据库,SQLite 引擎不是一个独立的进程,可以按应用程序需求进行静态或动态连接。SQLite 直接访问其存储文件。

所有教程参考地址: http://www.runoob.com/sqlite/sqlite-intro.html

22 Oct 2014 #Database #SQLite

iOS HTTP Multipart Forms POST(头像图片上传)

iOS

由于iOS无法通过html表单来上传图片,因此想要上传图片,必须实现http请求,而不能像其他语言那样通过html表单的post就能上传。

上传图片的http post请求的格式是这样的:

Content-type: multipart/form-data, boundary=---------------------------14737809831466499882746641449

---------------------------14737809831466499882746641449
Content-Disposition: form-data; name="pic"; filename="boo.jpg"
Content-Type: image/jpeg

... contents of boo,jpg ...
---------------------------14737809831466499882746641449
Content-Disposition: form-data; name="info"

Hello Boris!
---------------------------14737809831466499882746641449

13 Sep 2014 #iOS #http

关于宏

iOS

C中的宏分为两类,对象宏(object-like macro)和函数宏(function-like macro)。对于对象宏来说确实相对简单,但却也不是那么简单的查找替换。对象宏一般用来定义一些常数,举个例子:

#define M_PI    3.14159265358979323846264338327950288

#define关键字表明即将开始定义一个宏,紧接着的M_PI是宏的名字,空格之后的数字是内容。类似这样的#define X A的宏是比较简单的,在编译时编译器会在语义分析认定是宏后,将X替换为A,这个过程称为宏的展开。比如对于上面的M_PI直接使用。

9 Aug 2014 #iOS #macro

关于FMDB/SQLite

Database

https://github.com/ccgus/fmdb 下载源文件,然后直接将fmdb文件夹拖入到你的工程就OK。 当然你需要添加依赖库:libsqlite3.dylib

拖入源文件,并且添加依赖库以后你就可以使用FMDB了,引用头文件 #import "FMDB.h"

18 Jul 2014 #iOS #FMDB #Database

NSNotification 通知

iOS

NSNotification 一个对象通知另外一个对象,可以用来传递参数、通信等作用,与delegate的一对一不同,通知是一对多的。在一个对象中注册了通知,那么其他任意对象都可以来对这个对象发出通知。

  • NSNotificationCenter
  • NSNotificationQueue

3 Jul 2014 #iOS #NSNotification

有关block

iOS

block发生引用循环

一个对象中强引用了block,在block中又使用了该对象,就会发生循环引用。解决方法就是将该对象使用 __weak或者 __block 修饰符修饰后在block中使用。

  1. id weak weakSelf = self, 或者 weak __typeof(&*self)weakSelf = self (可以将该方法设置为宏)
  2. id __block weakSelf = self;

29 Jun 2014 #iOS #block