-
Notifications
You must be signed in to change notification settings - Fork 0
/
atom.xml
executable file
·838 lines (653 loc) · 54.2 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[胖子汪洋的博客]]></title>
<link href="http://igiu1988.github.io/atom.xml" rel="self"/>
<link href="http://igiu1988.github.io/"/>
<updated>2013-11-05T14:45:59+08:00</updated>
<id>http://igiu1988.github.io/</id>
<author>
<name><![CDATA[汪洋]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[ios证书制作解惑]]></title>
<link href="http://igiu1988.github.io/blog/2013/11/05/ioszheng-shu-zhi-zuo-jie-huo/"/>
<updated>2013-11-05T14:06:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/11/05/ioszheng-shu-zhi-zuo-jie-huo</id>
<content type="html"><![CDATA[<p>这几天做了一个推送相关的需求,结果弄明白了一些以前关于证书的疑惑。</p>
<p>先起个头,再写!!!</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[ios无线发布]]></title>
<link href="http://igiu1988.github.io/blog/2013/11/05/ioswu-xian-fa-bu/"/>
<updated>2013-11-05T14:06:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/11/05/ioswu-xian-fa-bu</id>
<content type="html"><![CDATA[<p>先用adhoc方式打包应用。如果adhoc打包有问题,有转看我“ios证书制作解惑”。</p>
<p>剩下的东西也都是copy网上的,我只是稍加整理一下。server已经放到<a href="https://github.com/igiu1988/iosadhoc">github</a>上了。具体参看项目的README</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[shell替换文本]]></title>
<link href="http://igiu1988.github.io/blog/2013/11/05/shellti-huan-wen-ben/"/>
<updated>2013-11-05T13:45:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/11/05/shellti-huan-wen-ben</id>
<content type="html"><![CDATA[<h2>就记录一下sed替换文本的用法</h2>
<h4>该目录下的所有txt中的china替换为chinese</h4>
<p><code>sed -i '' 's,china,chinese,g' *.txt</code> 一个目录下的</p>
<h4>递归所有目录文件中的china替换为chinese</h4>
<p><code>find . -type f -exec sed -i '' 's,china,chinese,g' {} +</code></p>
<h4>下面的命令则是指定了搜索的文件类型,并替换这些文件中的指定内容</h4>
<p><code>find -name "*.txt" -exec sed -i 's,china,chinese,g' {} +</code></p>
<h4>递归查找包含指定字符串的文件:</h4>
<p><code>find . -type f -exec grep "http://10.5.31.143:8080" {} \;</code></p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[我机器的一些配置]]></title>
<link href="http://igiu1988.github.io/blog/2013/10/14/wo-ji-qi-de-xie-pei-zhi/"/>
<updated>2013-10-14T11:34:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/10/14/wo-ji-qi-de-xie-pei-zhi</id>
<content type="html"><![CDATA[<p>用brew安装tomcat,启动命令是catalina start</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Qt学习笔记]]></title>
<link href="http://igiu1988.github.io/blog/2013/10/14/qtxue-xi-bi-ji/"/>
<updated>2013-10-14T09:26:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/10/14/qtxue-xi-bi-ji</id>
<content type="html"><![CDATA[<h3>Qt学习笔记</h3>
<p>该笔记现处理杂乱无章的状态,等记得一定多了,再分类吧</p>
<ul>
<li>Qt工程目录写要创建在英文路径下,要不然会出现“qmake.exe”退出,退出代码 2”</li>
<li>explicit关键字的介绍<a href="http://blog.csdn.net/ma_nong/article/details/7696690">Qt C++中的关键字explicit</a></li>
<li><a href="http://xwz89314.blog.163.com/blog/static/40510004201012725354619/">Q_OBJECT宏</a></li>
<li>Qt中多继承时,QObject要排在第一位</li>
<li>Qt控制台输入内容,再转入QString,再转为char *</li>
</ul>
<p>“`</p>
<pre><code>QString qstr; QTextStream in(stdin); in>>qstr; std::string tempStr = qstr.toStdString(); const char* ch = tempStr.c_str();
</code></pre>
<p> “`</p>
<h3>关于一些错误的解决</h3>
<ul>
<li>比如你的项目名是AAA,运行时提示No rule to make target [路径]/AAA.pro for makefile。其实后面不是for makefile,不过大概的意思就是没有找到makefile中所对应的pro文件,在makefile文件中看一下你会发现pro文件的路径不对,直接用手改过来吗?当然不是。在Qt里对着该项目执行一下Qmake,再运行就ok了,这个问题通常发生在一个项目被移动了另一个地方,而原先的build目录还在引起的,也就是makefile没有被更新引起的。</li>
</ul>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[关于一周一算法]]></title>
<link href="http://igiu1988.github.io/blog/2013/10/09/about-one-algorithm-one-week/"/>
<updated>2013-10-09T12:26:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/10/09/about-one-algorithm-one-week</id>
<content type="html"><![CDATA[<h3>为什么要写</h3>
<p>大学时老师到是讲了不少算法,可是我哪个也没有背下来,实话是我从来没有背过!!!我是顿悟了吗?要学习了吗?反正得逼着自己学点什么吧,把算法也加入其中吧。</p>
<!--more-->
<h3>会涉及到什么</h3>
<p>先从基础的一些排序写起,逐渐深入
* 排序
* 矩阵、线性变换
* 树、图
* 大学数学中曾经学到的一些公式</p>
<h3>内容特点</h3>
<p>我必须考虑这些东西的实际用途</p>
<h3>写作周期</h3>
<p>做到一周一篇,内容过多就拆分</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[python 学习笔记]]></title>
<link href="http://igiu1988.github.io/blog/2013/10/09/note-on-python/"/>
<updated>2013-10-09T09:28:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/10/09/note-on-python</id>
<content type="html"><![CDATA[<h3>记录我使用python过程中遇到的各种问题</h3>
<!--more-->
<h5>程序块的开始要使用冒号来标识,用缩进来表示这段代码都属于一个程序块。</h5>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>def foo(list):
</span><span class='line'> for item in list:
</span><span class='line'> newItem = item + 5
</span><span class='line'> print item
</span><span class='line'> if list[1] == '1':
</span><span class='line'> print "equal"
</span><span class='line'> else:
</span><span class='line'> print "not equal"
</span><span class='line'>
</span><span class='line'>list = ['1', '2', '4']
</span><span class='line'>foo (list)</span></code></pre></td></tr></table></div></figure>
<h5>在序列中用引号与不用引号是不一样的</h5>
<p>下面代码里的两个list是不一样的</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>list1 = ['1', '2', '4']
</span><span class='line'>if list1[0] == '1':
</span><span class='line'> print 'YES'
</span><span class='line'>
</span><span class='line'>list2 = [1, 2, 4]
</span><span class='line'>if list2[0] == 1:
</span><span class='line'> print 'YES'</span></code></pre></td></tr></table></div></figure>
<h5>range后面用的是括号!!!</h5>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[普通冒泡排序]]></title>
<link href="http://igiu1988.github.io/blog/2013/09/30/bubblesort/"/>
<updated>2013-09-30T10:27:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/09/30/bubblesort</id>
<content type="html"><![CDATA[<h3>本文参考了的一些文章</h3>
<h5>冒泡排序</h5>
<ul>
<li><a href="http://blog.csdn.net/lengyuhong/article/details/4659552">lengyuhong的专栏-冒泡算法的优化</a></li>
<li><a href="https://github.com/linuz/Bubble-Sort/blob/master/bubblesort.py">github: linuz/Bubble-Sort</a></li>
<li><a href="http://www.cppblog.com/shongbee2/archive/2009/04/25/81038.aspx">冒泡排序</a></li>
</ul>
<h5>选择排序</h5>
<ul>
<li><a href="http://www.cppblog.com/shongbee2/archive/2009/04/25/81040.html">选择排序</a></li>
</ul>
<h2>关于冒泡</h2>
<h4>思想</h4>
<ul>
<li>从数组的第一个元素开始,两两比较,大的往后放,经过n-1次比较,最大的放到了n-1位置。</li>
<li>从数组的第一个元素开始,两两比较,大的往后放,经过n-2次比较,第二大的放在了n-2位置。</li>
<li>以此类推</li>
</ul>
<!--more-->
<h4>尼玛!!!这也不像冒泡啊</h4>
<p>不知道有没有人也像我这么想过:乍一看,每一次都是将最大的放在了最后面(沉底),这怎么是冒泡!!!尼玛!!!
<img src="http://f.hiphotos.bdimg.com/album/s%3D1600%3Bq%3D90/sign=47abf7a0a60f4bfb88d09a52337f4381/0df431adcbef76098e9f01a02cdda3cc7cd99e7d.jpg" alt="image" /></p>
<p>其实今天我才想明白,虽然每次都是将最大的放在最后,可是从另一方面来看,也就是说每一次都是将其余小的放在了上面,也就可以想成小的往上升,称之为冒泡排序。如果还是不行,可以看下面的流程,我们从更加形象的流程来描述冒泡排序的思想。</p>
<ul>
<li>从数组<font color = red><strong><em>最后一个元素</em></strong></font>开始,将相邻的挨个比较,小的往前放,经过n-1次比较,最小的就放到了最前面。</li>
<li>仍然从<font color = red><strong><em>最后一个元素</em></strong></font>开始,经过n-2次比较,第二小的放在了第二位置。</li>
<li>以此类推</li>
</ul>
<h4>写段python代码</h4>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>def bubbleSort(list):
</span><span class='line'> issorted = False
</span><span class='line'>
</span><span class='line'> for i in range(0,len(list)):
</span><span class='line'> issorted = True
</span><span class='line'>
</span><span class='line'> # 在这一趟的比较中,如果发现这一趟的数列已经成有序状态,那就不用排了,并且是整个数列也都算排完了
</span><span class='line'> for j in range(0, len(list) - i - 1):
</span><span class='line'> if list[j] > list[j+1]:
</span><span class='line'> temp = list[j]
</span><span class='line'> list[j] = list[j+1]
</span><span class='line'> list[j + 1] = temp
</span><span class='line'> issorted = False;
</span><span class='line'> print "sort ",i, " " , list
</span><span class='line'> if (issorted):
</span><span class='line'> break;
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>list = [7, 4, 1, 3, 9, 2, 8]
</span><span class='line'>bubbleSort(list)</span></code></pre></td></tr></table></div></figure>
<h4>总结</h4>
<ul>
<li>小的(轻的)逐渐上升到指定位置,从过程来看像冒泡(bubble sort)。</li>
<li>每一次相邻比较数组都<font color = red><strong><em>有可能</em></strong></font>会发现变化。</li>
</ul>
<h2>选择排序</h2>
<p>每一趟从待排序的数据元素中选出最小(或最大)的一个元素,比较时并不改变数组元素位置,至到一趟比较结束后,才将最小(最大)的元素与首元素(尾元素)交换位置</p>
<p>下面以排出由小到大的数组为例
以数组array[]为例,选择0位置为最小元素位置,用局部变量temp记住当前的index:0
* 用array[0]与其它位置元素比较,如果array[x]小于array[0],temp = x,使用array[x]与剩下元素比较,如果array[y] < array[x], temp = y。直到全部比较完,此时的temp是最小元素的下村,将array[temp]与array[0]交换位置
* 用array[1]重复上面的步骤</p>
<h2>什么是稳定的排序</h2>
<p>通俗地讲就是能保证排序前2个相等的数其在序列的前后位置顺序和排序后它们两个的前后位置顺序相同。在简单形式化一下,如果Ai = Aj, 排序前Ai在Aj前,那么排序后Ai仍然在Aj前。
* 冒泡是稳定的
* 选择是不稳定的</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[开发笔记 1]]></title>
<link href="http://igiu1988.github.io/blog/2013/09/22/develop-note-1/"/>
<updated>2013-09-22T14:33:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/09/22/develop-note-1</id>
<content type="html"><![CDATA[<h3>viewWillAppear 与 viewWillLayoutSubviews</h3>
<ul>
<li>viewWillLayoutSubviews 只在controller要显示时才会走一遍。viewWillAppear则会再被push、modal或者pop back时都会走一次</li>
<li>viewWillLayoutSubviews 在viewDidLoad后会走一次。在运行时如果addsubview时会走再走一次。</li>
</ul>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Xcode 高级调试]]></title>
<link href="http://igiu1988.github.io/blog/2013/08/05/power-your-debug-in-xcode/"/>
<updated>2013-08-05T10:29:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/08/05/power-your-debug-in-xcode</id>
<content type="html"><![CDATA[<p>在 Xcode 里 debug 时你会不会有这种想法:在一个 for 循环里,我只需要在 i==102时才开始 debug;或者一个比较实际的例子,我想在 tableView:cellForRowAtIndexPath:当 indexPath 是[15, 0]才开始 debug。
我肯定有那么一部分人会和我一样在那个地方写一个类似这样的代码,在 nslog 处打个断点。</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="k">if</span> <span class="p">(</span><span class="n">i</span> <span class="o">==</span> <span class="mi">102</span><span class="p">)</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="n">NSLog</span><span class="p">(</span><span class="s">@"a"</span><span class="p">);</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>看完这篇文章你就不需要这么做了,你会知道更多高级的技巧。<strong><font color='red' size='5'>Power your debug in xcode!!!</font></strong></p>
<p>该文包括</p>
<ul>
<li>让断点在合适的时候停下</li>
<li>断点条件语法注意</li>
<li>在断点条件发生时执行特别的任务</li>
<li>在调试时改变变量的值</li>
</ul>
<!--more-->
<h2>让断点在合适的时候停下</h2>
<p>在断点箭头上右键,Edit Breakpoint,在 Conditions 里添加断点条件。解释图1.</p>
<p>下面这段代码取自一个 for 循环,<code>for (int i = 0; i < _channels.count; i++)</code> , 我想在 i == _channels.count – 2 时开始进行断点调试。如图添加断点条件,然后运行一下,你就会发现奇迹了。</p>
<p style="text-align:center;"><img src="http://h.hiphotos.bdimg.com/album/s%3D550%3Bq%3D90%3Bc%3Dxiangce%2C100%2C100/sign=f3d78ed918d8bc3ec20806cfb2b0d723/810a19d8bc3eb135acac8c58a71ea8d3fc1f44ed.jpg?referer=e248dcc80ff41bd58344dcc4a4a3&x=.jpg" alt="断点条件" /></p>
<p style="text-align:center;">图1</p>
<h2>断点条件语法注意</h2>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="n">i</span> <span class="o">>=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)[</span><span class="n">_channels</span> <span class="n">count</span><span class="p">]</span> <span class="o">-</span> <span class="mi">2</span>
</span></code></pre></td></tr></table></div></figure>
<p>我猜想,这个功能是 xcode 基于调试器(GDB或者LLDB)的高级封装,所以一些调试语句的语法仍要使用调试器能够支持的语法。
<strong>比如图1中的测试条件,如果写成_channels.count,那么调试器会报错。所以我们就注意些,本来可以使用 dot 语法的都改为使用相应的 get 语法。</strong></p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="n">Error</span> <span class="n">parsing</span> <span class="n">breakpoint</span> <span class="n">condition</span><span class="p">.</span> <span class="n">Will</span> <span class="n">try</span> <span class="n">again</span> <span class="n">when</span> <span class="n">we</span> <span class="n">hit</span> <span class="n">the</span> <span class="n">breakpoint</span><span class="p">.</span><span class="n">Error</span> <span class="n">parsing</span> <span class="n">breakpoint</span> <span class="n">condition</span><span class="p">.</span> <span class="n">Will</span> <span class="n">try</span> <span class="n">again</span> <span class="n">when</span> <span class="n">we</span> <span class="n">hit</span> <span class="n">the</span> <span class="n">breakpoint</span><span class="p">.(</span><span class="n">gdb</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<p><strong>可以加上数据类型说明的就加上,比如(int)。</strong></p>
<h2>在断点条件发生时执行特别的任务</h2>
<p>可能你也发现了,在图1的断点条件编辑框里有一个 Actions 功能,对!就是这儿,你可以通过添加一个 Debugger Command 加上你想要的调试语句,比如 p i</p>
<h2>在调试时改变变量的值</h2>
<p>可以在 Actions 里添加Debugger Command,比如执行一个 set var m=10。</p>
<hr />
<h3>参考</h3>
<ul>
<li><a href="http://www.cimgf.com/2012/12/13/xcode-lldb-tutorial/">XCODE LLDB TUTORIAL</a></li>
<li><a href="http://www.delorie.com/gnu/docs/gdb/gdb_118.html">Debugging with GDB – Assignment to variables</a></li>
</ul>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Core Animation Notes 1]]></title>
<link href="http://igiu1988.github.io/blog/2013/06/28/core-animation-notes-1/"/>
<updated>2013-06-28T08:49:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/06/28/core-animation-notes-1</id>
<content type="html"><![CDATA[<h2>废话</h2>
<p>看Core Animation相关的例子不下10次,只有最近一次才看得算是明白,然后又看了一点文档。我不是什么爱学习的人,也不想特意去先学习点什么东西以便留着以后用。我只是碰到了,我就看,看不明白拉倒,哪天碰到了再看,总有一天能看明白。</p>
<p>瞅了一眼Core Animation Basics,看完就忘记了,不得已一边再看一遍文档,一边写文章了。</p>
<h2>上一段代码</h2>
<p>经常的,想实现一个动画,或者只是想看看这个动画怎么写的布局,那就看一下别人写的代码呗。一看,我了个去,看不明白啊。好吧,整个简单的代码先看看</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="k">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">scaleLabel:</span><span class="p">(</span><span class="n">UILabel</span> <span class="o">*</span><span class="p">)</span><span class="nv">label</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="p">[</span><span class="n">label</span><span class="p">.</span><span class="n">layer</span> <span class="nl">removeAnimationForKey:</span><span class="s">@"transform.scale"</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'> <span class="n">CABasicAnimation</span> <span class="o">*</span><span class="n">pulseAnimation</span> <span class="o">=</span> <span class="p">[</span><span class="n">CABasicAnimation</span> <span class="nl">animationWithKeyPath:</span><span class="s">@"transform.scale"</span><span class="p">];</span>
</span><span class='line'> <span class="n">pulseAnimation</span><span class="p">.</span><span class="n">duration</span> <span class="o">=</span> <span class="mf">.3</span><span class="p">;</span>
</span><span class='line'> <span class="n">pulseAnimation</span><span class="p">.</span><span class="n">toValue</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSNumber</span> <span class="nl">numberWithFloat:</span><span class="mf">1.05</span><span class="p">];</span>
</span><span class='line'> <span class="n">pulseAnimation</span><span class="p">.</span><span class="n">timingFunction</span> <span class="o">=</span> <span class="p">[</span><span class="n">CAMediaTimingFunction</span> <span class="nl">functionWithName:</span><span class="n">kCAMediaTimingFunctionLinear</span><span class="p">];</span>
</span><span class='line'> <span class="n">pulseAnimation</span><span class="p">.</span><span class="n">autoreverses</span> <span class="o">=</span> <span class="n">YES</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="p">[</span><span class="n">label</span><span class="p">.</span><span class="n">layer</span> <span class="nl">addAnimation:</span><span class="n">pulseAnimation</span> <span class="nl">forKey:</span><span class="nb">nil</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<!--more-->
<h2>它干了什么</h2>
<p>这个代码简单些,大概知道干了什么事,是要进行放大操作,放大到1.05倍,时间0.3s,autoreverses意思是自己恢复,timingFunction的意思在文档里写的我没看懂,英语太次,google了一下,找到一个词,感觉挺形象,elastic function,可以直白的翻译成“松紧函数”,或者说是“弹性函数”。上面代码里用的是kCAMediaTimingFunctionEaseIn,放大动画的运行效果是会先慢后快(渐入),当然如果是EaseInEaseOut,那就是渐入渐出。elastic function这个词我取自<a href="http://stackoverflow.com/questions/5161465/how-to-create-custom-easing-function-with-core-animation">该文章</a>,文章里有自定义elastic function的内容,值得阅读。</p>
<p>对于上面代码有一点要注意:就是首先要先removeAnimationForKey。</p>
<h2>什么时候调用</h2>
<p>当你想让这个label执行一次动画时,就调用一次</p>
<h2>想加多个动画到这个Label上怎么办</h2>
<p>先上一段代码</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="k">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">animationGroup:</span><span class="p">(</span><span class="n">UILabel</span> <span class="o">*</span><span class="p">)</span><span class="nv">label</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="p">[</span><span class="n">label</span><span class="p">.</span><span class="n">layer</span> <span class="nl">removeAnimationForKey:</span><span class="s">@"animationGroup"</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'> <span class="n">CABasicAnimation</span> <span class="o">*</span><span class="n">pulseAnimation</span> <span class="o">=</span> <span class="p">[</span><span class="n">CABasicAnimation</span> <span class="nl">animationWithKeyPath:</span><span class="s">@"transform.scale"</span><span class="p">];</span>
</span><span class='line'> <span class="n">pulseAnimation</span><span class="p">.</span><span class="n">duration</span> <span class="o">=</span> <span class="mf">2.</span><span class="p">;</span>
</span><span class='line'> <span class="n">pulseAnimation</span><span class="p">.</span><span class="n">toValue</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSNumber</span> <span class="nl">numberWithFloat:</span><span class="mf">1.15</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'> <span class="n">CABasicAnimation</span> <span class="o">*</span><span class="n">pulseColorAnimation</span> <span class="o">=</span> <span class="p">[</span><span class="n">CABasicAnimation</span> <span class="nl">animationWithKeyPath:</span><span class="s">@"backgroundColor"</span><span class="p">];</span>
</span><span class='line'> <span class="n">pulseColorAnimation</span><span class="p">.</span><span class="n">duration</span> <span class="o">=</span> <span class="mf">1.</span><span class="p">;</span>
</span><span class='line'> <span class="n">pulseColorAnimation</span><span class="p">.</span><span class="n">fillMode</span> <span class="o">=</span> <span class="n">kCAFillModeForwards</span><span class="p">;</span>
</span><span class='line'> <span class="n">pulseColorAnimation</span><span class="p">.</span><span class="n">toValue</span> <span class="o">=</span> <span class="p">(</span><span class="kt">id</span><span class="p">)[</span><span class="n">UIColorFromRGBA</span><span class="p">(</span><span class="mh">0xFF0000</span><span class="p">,</span> <span class="mf">.75</span><span class="p">)</span> <span class="n">CGColor</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'> <span class="n">CABasicAnimation</span> <span class="o">*</span><span class="n">rotateLayerAnimation</span> <span class="o">=</span> <span class="p">[</span><span class="n">CABasicAnimation</span> <span class="nl">animationWithKeyPath:</span><span class="s">@"transform.rotation"</span><span class="p">];</span>
</span><span class='line'> <span class="n">rotateLayerAnimation</span><span class="p">.</span><span class="n">duration</span> <span class="o">=</span> <span class="mf">.5</span><span class="p">;</span>
</span><span class='line'> <span class="n">rotateLayerAnimation</span><span class="p">.</span><span class="n">beginTime</span> <span class="o">=</span> <span class="mf">.5</span><span class="p">;</span>
</span><span class='line'> <span class="n">rotateLayerAnimation</span><span class="p">.</span><span class="n">fillMode</span> <span class="o">=</span> <span class="n">kCAFillModeBoth</span><span class="p">;</span>
</span><span class='line'> <span class="n">rotateLayerAnimation</span><span class="p">.</span><span class="n">toValue</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSNumber</span> <span class="nl">numberWithFloat:</span><span class="n">DEGREES_TO_RADIANS</span><span class="p">(</span><span class="mf">45.</span><span class="p">)];</span>
</span><span class='line'>
</span><span class='line'> <span class="n">CAAnimationGroup</span> <span class="o">*</span><span class="n">group</span> <span class="o">=</span> <span class="p">[</span><span class="n">CAAnimationGroup</span> <span class="n">animation</span><span class="p">];</span>
</span><span class='line'> <span class="n">group</span><span class="p">.</span><span class="n">animations</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSArray</span> <span class="nl">arrayWithObjects:</span><span class="n">pulseAnimation</span><span class="p">,</span> <span class="n">pulseColorAnimation</span><span class="p">,</span> <span class="n">rotateLayerAnimation</span><span class="p">,</span> <span class="nb">nil</span><span class="p">];</span>
</span><span class='line'> <span class="n">group</span><span class="p">.</span><span class="n">duration</span> <span class="o">=</span> <span class="mf">2.</span><span class="p">;</span>
</span><span class='line'> <span class="n">group</span><span class="p">.</span><span class="n">timingFunction</span> <span class="o">=</span> <span class="p">[</span><span class="n">CAMediaTimingFunction</span> <span class="nl">functionWithName:</span><span class="n">kCAMediaTimingFunctionEaseInEaseOut</span><span class="p">];</span>
</span><span class='line'> <span class="n">group</span><span class="p">.</span><span class="n">autoreverses</span> <span class="o">=</span> <span class="n">YES</span><span class="p">;</span>
</span><span class='line'> <span class="n">group</span><span class="p">.</span><span class="n">repeatCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="p">[</span><span class="n">label</span><span class="p">.</span><span class="n">layer</span> <span class="nl">addAnimation:</span><span class="n">group</span> <span class="nl">forKey:</span><span class="s">@"animationGroup"</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>最后用一个CAAnimationGroup来管理所有的动画,自己去看一下CAAnimationGroup Class Reference,里面有些注意事项需要注意。</p>
<h2>提出问题</h2>
<p>上面讲的这些都是直接在某个已经存在的view.layer上操作,如果想实现一个类似如下效果该怎么办</p>
<p>解决方法:
– 以动画所需要的内容创建一个layer
– 给layer添加一些动画
– 将layer添加到mainView上
– 动画结束,删除该layer</p>
<h2>只说解决方法的第一条</h2>
<p>如何创建一个layer,并让该layer显示我们需要的内容,直接上代码</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="k">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">createLayerWithContent:</span><span class="p">(</span><span class="n">UIView</span> <span class="o">*</span><span class="p">)</span><span class="nv">targetView</span> <span class="nf">InCoordinateSystem:</span><span class="p">(</span><span class="n">UIView</span> <span class="o">*</span><span class="p">)</span><span class="nv">coordinateSystemView</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="n">UIGraphicsBeginImageContext</span><span class="p">(</span><span class="n">targetView</span><span class="p">.</span><span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">);</span>
</span><span class='line'> <span class="n">CGContextRef</span> <span class="n">context</span> <span class="o">=</span> <span class="n">UIGraphicsGetCurrentContext</span><span class="p">();</span>
</span><span class='line'> <span class="c1">// 将targetView的内容渲染到context中</span>
</span><span class='line'> <span class="p">[</span><span class="n">targetView</span><span class="p">.</span><span class="n">layer</span> <span class="nl">renderInContext:</span><span class="n">context</span><span class="p">];</span>
</span><span class='line'> <span class="c1">// 从context中取得该图片</span>
</span><span class='line'> <span class="n">CGImageRef</span> <span class="n">imgRef</span> <span class="o">=</span> <span class="n">CGBitmapContextCreateImage</span><span class="p">(</span><span class="n">context</span><span class="p">);</span>
</span><span class='line'> <span class="c1">// UIImage *contextImage = UIGraphicsGetImageFromCurrentImageContext();</span>
</span><span class='line'> <span class="n">UIGraphicsEndImageContext</span><span class="p">();</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">//使用imgRef创建一个layer</span>
</span><span class='line'> <span class="n">CALayer</span> <span class="o">*</span><span class="n">layer</span> <span class="o">=</span> <span class="p">[[</span><span class="n">CALayer</span> <span class="n">alloc</span><span class="p">]</span> <span class="n">init</span><span class="p">];</span>
</span><span class='line'> <span class="n">layer</span><span class="p">.</span><span class="n">contents</span> <span class="o">=</span> <span class="p">(</span><span class="n">__bridge</span> <span class="kt">id</span><span class="p">)</span><span class="n">imgRef</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// 指定其frame,并添加到coordinateSystemView.layer</span>
</span><span class='line'> <span class="n">layer</span><span class="p">.</span><span class="n">frame</span> <span class="o">=</span> <span class="p">[</span><span class="n">coordinateSystemView</span> <span class="nl">convertRect:</span><span class="n">targetView</span><span class="p">.</span><span class="n">frame</span> <span class="nl">fromView:</span><span class="n">targetView</span><span class="p">.</span><span class="n">superview</span><span class="p">];</span>
</span><span class='line'> <span class="p">[</span><span class="n">coordinateSystemView</span><span class="p">.</span><span class="n">layer</span> <span class="nl">addSublayer:</span><span class="n">transitionLayer</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'>
</span><span class='line'> <span class="c1">// TODO: some code to animate the layer</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>targetView就要是展现的动画层,新layer的内容就是从targetView中渲染过来的
coordinateSystemView应该是动画层所在的父view</p>
<p>对于CGContextRef也有很多可以利用的方法,比如裁剪,旋转,绽放,具体自己google
对于CALayer当然也有很多属性,比如设置透明度,背景色等。</p>
<h2>几大动画方式</h2>
<ul>
<li>CABasicAnimation</li>
<li>CAKeyframeAnimation</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="n">UIGraphicsBeginImageContext</span><span class="p">(</span><span class="n">targetView</span><span class="p">.</span><span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">);</span>
</span><span class='line'> <span class="n">CGContextRef</span> <span class="n">context</span> <span class="o">=</span> <span class="n">UIGraphicsGetCurrentContext</span><span class="p">();</span>
</span><span class='line'> <span class="p">[</span><span class="n">targetView</span><span class="p">.</span><span class="n">layer</span> <span class="nl">renderInContext:</span><span class="n">context</span><span class="p">];</span>
</span><span class='line'> <span class="n">CGImageRef</span> <span class="n">imgRef</span> <span class="o">=</span> <span class="n">CGBitmapContextCreateImage</span><span class="p">(</span><span class="n">context</span><span class="p">);</span>
</span><span class='line'> <span class="n">UIGraphicsEndImageContext</span><span class="p">();</span>
</span></code></pre></td></tr></table></div></figure>
<h2>贝赛尔曲线</h2>
<h2>什么时候使用CATransaction</h2>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Octopress配置]]></title>
<link href="http://igiu1988.github.io/blog/2013/06/06/octpress-set-up/"/>
<updated>2013-06-06T12:30:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/06/06/octpress-set-up</id>
<content type="html"><![CDATA[<h2>修改默认的markdown文件</h2>
<p>每次使用rake post时产生的新文件中都有如下格式:</p>
<pre>
layout: post
title: "Octopress配置"
date: 2013-06-06 12:30
comments: true
keywords: octopress //默认是没有这行的
categories:
</pre>
<p>如果想自定义这里的内容,比如添加一个key,<!--more-->比如上面的keywords,那么就修改Rakefile,搜索<code>layout:</code>你就知道接下来怎么做了。</p>
<h2>让google search结果显示你的google+头像</h2>
<ul>
<li>在<a href="https://www.google.com.hk/webmasters/tools/richsnippets?q=www.catcrazy.cn&html=">Structured Data Testing Tool</a>中测试是否已经正确设置</li>
<li>在<a href="http://support.google.com/webmasters/bin/answer.py?hl=en&answer=1408986">Author information in search results
</a>中了解更多关于这方面东西</li>
<li>其它方面自己google吧
<img src="testGoogle.png" alt="testGoogle" />
<img src="http://igiu1988.github.io/images/testGoogle.png"></li>
</ul>
<h2>首页只显示正文</h2>
<p>如果你只想让博客首页在显示该博文时只显示到某一处,那就在那儿添加一个<code><!--more--></code>。首页会多出一个继续阅读的链接,试一试就知道了。</p>
<h2>我所参考的几个博客</h2>
<ul>
<li><a href="http://www.yanjiuyanjiu.com/blog/20130402/">我的Octopress</a></li>
<li><a href="http://octopress.org/docs/">octopress官方文档</a></li>
<li><a href="http://linyi.herokuapp.com/blog/config-octopress.html">octopress的个性化配置</a></li>
<li><a href="http://whbzju.github.io/blog/2013/03/01/octopress-custom-config/">涉及导航,分类,sina,评论</a></li>
<li><a href="http://khaos.github.io/blog/2012/12/06/using-chinese-category-tags-in-octopress/">Octopress易筋经,中文分类标签</a></li>
<li>[]</li>
</ul>
<h2>迁移你的博客系统</h2>
<ul>
<li><a href="http://blog.zerosharp.com/clone-your-octopress-to-blog-from-two-places/">Clone Your Octopress to Blog From Two Places</a></li>
</ul>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[iOS Core Data 入门]]></title>
<link href="http://igiu1988.github.io/blog/2013/06/04/ios-core-data-guide/"/>
<updated>2013-06-04T15:29:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/06/04/ios-core-data-guide</id>
<content type="html"><![CDATA[<p>做了一年多iOS开发,真没怎么用过Core Data,来新公司一直没有活,就看Core Data了。网上一搜一大把关于Core Data的教程,我以我自己的方式重新再说一次,如看不懂就再自己搜索吧。</p>
<h2>注意</h2>
<p>Core Data不是数据库,只是对SQLite的封装,集成了很多内容,并且高效。</p>
<h2>开始</h2>
<p>我新建了一个类,SQLManager : NSObject</p>
<p>添加了一个类方法,目的是全局使用一个SQLManager对象</p>
<!--more-->
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="k">+</span> <span class="p">(</span><span class="n">SQLManager</span> <span class="o">*</span><span class="p">)</span><span class="nf">sharedSQLManager</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">static</span> <span class="n">dispatch_once_t</span> <span class="n">onceToken</span><span class="p">;</span>
</span><span class='line'> <span class="k">static</span> <span class="kt">id</span> <span class="n">shareInstance</span><span class="p">;</span>
</span><span class='line'> <span class="n">dispatch_once</span><span class="p">(</span><span class="o">&</span><span class="n">onceToken</span><span class="p">,</span> <span class="o">^</span><span class="p">{</span>
</span><span class='line'> <span class="n">shareInstance</span> <span class="o">=</span> <span class="p">[[</span><span class="n">self</span> <span class="n">alloc</span><span class="p">]</span> <span class="n">init</span><span class="p">];</span>
</span><span class='line'> <span class="p">});</span>
</span><span class='line'>
</span><span class='line'> <span class="k">return</span> <span class="n">shareInstance</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>Core Data涉及三个对象是肯定每次都要用的的</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="k">@property</span> <span class="p">(</span><span class="n">nonatomic</span><span class="p">,</span> <span class="n">strong</span><span class="p">)</span> <span class="n">NSManagedObjectModel</span> <span class="o">*</span><span class="n">managedObjectModel</span><span class="p">;</span>
</span><span class='line'><span class="k">@property</span> <span class="p">(</span><span class="n">nonatomic</span><span class="p">,</span> <span class="n">strong</span><span class="p">)</span> <span class="n">NSManagedObjectContext</span> <span class="o">*</span><span class="n">managedObjectContext</span><span class="p">;</span>
</span><span class='line'><span class="k">@property</span> <span class="p">(</span><span class="n">nonatomic</span><span class="p">,</span> <span class="n">strong</span><span class="p">)</span> <span class="n">NSPersistentStoreCoordinator</span> <span class="o">*</span><span class="n">persistentStoreCoordinator</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>
<p>使用一个initCoreData来初始化这三个对象(SQLManager的属性)</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="k">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">initCoreData</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="c1">// 既然涉及数据库,肯定要有一个文件来存储数据</span>
</span><span class='line'> <span class="n">NSArray</span> <span class="o">*</span><span class="n">paths</span> <span class="o">=</span> <span class="n">NSSearchPathForDirectoriesInDomains</span><span class="p">(</span><span class="n">NSDocumentDirectory</span><span class="p">,</span> <span class="n">NSUserDomainMask</span><span class="p">,</span> <span class="n">YES</span><span class="p">);</span>
</span><span class='line'> <span class="n">NSString</span> <span class="o">*</span><span class="n">basePath</span> <span class="o">=</span> <span class="p">[</span><span class="n">paths</span> <span class="nl">objectAtIndex:</span><span class="mi">0</span><span class="p">];</span>
</span><span class='line'> <span class="n">NSURL</span> <span class="o">*</span><span class="n">storeUrl</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSURL</span> <span class="nl">fileURLWithPath:</span><span class="p">[</span><span class="n">basePath</span> <span class="nl">stringByAppendingPathComponent:</span><span class="s">@"TestDB.sqlite"</span><span class="p">]];</span>
</span><span class='line'>
</span><span class='line'> <span class="cm">/* 初始化 managedObjectModel </span>
</span><span class='line'><span class="cm"> * managedObjectModel 的初始化是依据工程中的xcdatamodeld文件,</span>
</span><span class='line'><span class="cm"> */</span>
</span><span class='line'> <span class="n">_managedObjectModel</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSManagedObjectModel</span> <span class="nl">mergedModelFromBundles:</span><span class="nb">nil</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'> <span class="cm">/* 初始化 persistentStoreCoordinator</span>
</span><span class='line'><span class="cm"> * persistentStoreCoordinator 的初始化需要刚才的 managedObjectModel,这里我添加了一个option,该option会在数据库的版本控制及轻量迁移中用到。</span>
</span><span class='line'><span class="cm"> * 数据库的版本控制及轻量迁移见另一篇文章: iOS Core Data Version</span>
</span><span class='line'><span class="cm"> */</span>
</span><span class='line'> <span class="n">NSError</span> <span class="o">*</span><span class="n">error</span><span class="p">;</span>
</span><span class='line'> <span class="c1">// option use for lightweight migration</span>
</span><span class='line'> <span class="n">NSDictionary</span> <span class="o">*</span> <span class="n">option</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSDictionary</span> <span class="nl">dictionaryWithObjectsAndKeys:</span>
</span><span class='line'> <span class="p">[</span><span class="n">NSNumber</span> <span class="nl">numberWithBool:</span><span class="n">YES</span><span class="p">],</span> <span class="n">NSMigratePersistentStoresAutomaticallyOption</span><span class="p">,</span>
</span><span class='line'> <span class="p">[</span><span class="n">NSNumber</span> <span class="nl">numberWithBool:</span><span class="n">YES</span><span class="p">],</span> <span class="n">NSInferMappingModelAutomaticallyOption</span><span class="p">,</span> <span class="nb">nil</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'> <span class="n">_persistentStoreCoordinator</span> <span class="o">=</span> <span class="p">[[</span><span class="n">NSPersistentStoreCoordinator</span> <span class="n">alloc</span><span class="p">]</span> <span class="nl">initWithManagedObjectModel:</span><span class="n">_managedObjectModel</span><span class="p">];</span>
</span><span class='line'> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">[</span><span class="n">_persistentStoreCoordinator</span> <span class="nl">addPersistentStoreWithType:</span><span class="n">NSSQLiteStoreType</span> <span class="nl">configuration:</span><span class="nb">nil</span> <span class="nl">URL:</span><span class="n">storeUrl</span> <span class="nl">options:</span><span class="n">option</span> <span class="nl">error:</span><span class="o">&</span><span class="n">error</span><span class="p">])</span> <span class="p">{</span>
</span><span class='line'> <span class="n">NSLog</span><span class="p">(</span><span class="s">@"%@: %@"</span><span class="p">,</span> <span class="p">[[[</span><span class="n">NSBundle</span> <span class="n">mainBundle</span><span class="p">]</span> <span class="n">infoDictionary</span><span class="p">]</span> <span class="nl">objectForKey:</span><span class="s">@"CFBundleDisplayName"</span><span class="p">],</span> <span class="n">error</span><span class="p">.</span><span class="n">localizedDescription</span><span class="p">);</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'> <span class="cm">/* 初始化 managedObjectContext</span>
</span><span class='line'><span class="cm"> * managedObjectContext 的初始化需要上面的 persistentStoreCoordinator</span>
</span><span class='line'><span class="cm"> */</span>
</span><span class='line'> <span class="n">_managedObjectContext</span> <span class="o">=</span> <span class="p">[[</span><span class="n">NSManagedObjectContext</span> <span class="n">alloc</span><span class="p">]</span> <span class="n">init</span><span class="p">];</span>
</span><span class='line'> <span class="n">_managedObjectContext</span><span class="p">.</span><span class="n">persistentStoreCoordinator</span> <span class="o">=</span> <span class="n">_persistentStoreCoordinator</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>参考文档:</p>
<ul>
<li>Core Data Basics</li>
<li>Core Data Programming Gudie</li>
<li>google及baidu的各种搜索</li>
</ul>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[iMac蓝牙与wifi信号]]></title>
<link href="http://igiu1988.github.io/blog/2013/06/04/bluetooth-and-wifi-in-imac/"/>
<updated>2013-06-04T13:42:00+08:00</updated>
<id>http://igiu1988.github.io/blog/2013/06/04/bluetooth-and-wifi-in-imac</id>
<content type="html"><![CDATA[<p>在新公司终于使用上了iMac,甚是高兴,可是用着用着发现magic mouse总是掉帧,输入文字时偶尔也会变得很卡,鼠标的问题尤为严重,于是google之,的确有同样的问题。其中有一个帖子说是与其用的wifi信号频道(强度)有关系,于是将iMac连接到了公司的另一个wifi信号上,果然蓝牙设备不再掉帧了。具体原因我说不清,只提供一些证据</p>
<ul>
<li>iMac型号MD093CH/A,使用的无线芯片是Broadcom BCM43xx,集成了wifi与bluetooth</li>
<li>先前的wifi信号强度是-52dBm,后来的wifi信号强度是-26dBm</li>
<li>查看蓝牙设备的RSSI,基本都在-52dBm上下波动</li>
</ul>
]]></content>
</entry>
</feed>