forked from xujingbao/beyondvincent.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathatom.xml
More file actions
3753 lines (2486 loc) · 268 KB
/
atom.xml
File metadata and controls
3753 lines (2486 loc) · 268 KB
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
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[破船之家]]></title>
<link href="http://BeyondVincent.github.io/atom.xml" rel="self"/>
<link href="http://BeyondVincent.github.io/"/>
<updated>2013-09-27T17:50:29+08:00</updated>
<id>http://BeyondVincent.github.io/</id>
<author>
<name><![CDATA[破船(BeyondVincent)]]></name>
<email><![CDATA[beyondvincent@gmail.com]]></email>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[Sprite Kit初级教程(1)]]></title>
<link href="http://BeyondVincent.github.io/blog/2013/09/26/113-ios-7-spritekit-tutorial-for-beginners-1/"/>
<updated>2013-09-26T11:45:00+08:00</updated>
<id>http://BeyondVincent.github.io/blog/2013/09/26/113-ios-7-spritekit-tutorial-for-beginners-1</id>
<content type="html"><![CDATA[<p><img src="http://BeyondVincent.github.io/images/2013/09/6.png"></p>
<!--more-->
<p>注:本文译自<a href="http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners"><code>Sprite Kit Tutorial for Beginners</code></a></p>
<h3><strong>目录</strong></h3>
<ul>
<li><code>Sprite Kit的优点和缺点</code></li>
<li><code>Sprite Kit vs Cocos2D-iPhone vs Cocos2D-X vs Unity</code></li>
<li><code>Hello, Sprite Kit!</code></li>
<li>横屏显示</li>
<li>移动怪兽</li>
<li>发射炮弹</li>
<li>碰撞检测: 概述</li>
<li>碰撞检测: 实现</li>
<li>收尾</li>
<li>何去何从?</li>
</ul>
<p>在iOS 7中内置了一个新的Sprite Kit框架,该框架主要用来开发2D游戏。目前已经支持的内容包括:精灵、很酷的特效(例如视频、滤镜和遮罩),并且还集成了物理库等许多东西。</p>
<p>iOS 7中附带了一个非常棒的Sprite Kit示例工程,名字叫做Adventure。不过这个示例工程稍微有点复杂,不太适合初学者。本文的目的就是做一个关于Sprite Kit使用的初级教程。</p>
<p>通过本文,你可以从头到尾的学习到如何为你的iPhone创建一个简单又有趣的2D游戏。如果你看过我们之前的教程:<a href="http://www.raywenderlich.com/25736/how-to-make-a-simple-iphone-game-with-cocos2d-2-x-tutorial">Simple Cocos2D game教程</a>,你会发现非常的相似。</p>
<p>在开始之前,请确保已经安装了最新版本的Xcode(5.X),里面支持Sprite Kit以及iOS 7。</p>
<h3><strong> Sprite Kit的优点和缺点</strong></h3>
<p>首先,我想指出在iOS中开发2D游戏Sprite Kit并不是唯一的选择,下面我们先来看看Sprite Kit的一些优点和缺点。</p>
<p>Sprite Kit的优点:</p>
<p> 1、它是内置到iOS中的,因此并不需要下载额外的库或者其它一些外部依赖。并且它是由苹果开发的,所以对于它的支持和更新我们可以放心。</p>
<p> 2、它内置的工具支持纹理和粒子。</p>
<p> 3、它可以让你做一些其它框架很难做到的事情,例如把视频当做精灵一样处理,或者使用很酷的图形效果和遮罩。</p>
<p>Sprite Kit的缺点:</p>
<p> 1、如果使用了Sprite Kit,那么你将被iOS生态圈所绑架,导致你无法很容易对你开发的游戏移植到Android上。</p>
<p> 2、Sprite Kit现在还处于初始阶段,此时提供的功能还没有别的框架丰富,例如Cocos2D。最缺的东西应该是暂不支持写自定义的OpenGL代码。</p>
<h3><strong> Sprite Kit vs Cocos2D-iPhone vs Cocos2D-X vs Unity</strong></h3>
<p>此时,你可能在想“我该选择使用哪个2D框架呢?”</p>
<p>这取决于你的实际情况,下面是我的一些想法:</p>
<p> 1、如果你是一个初学者,并且只关注于iOS,那么就使用内置的Sprite Kit吧,它非常容易学习,并且完全可以把工作做好。</p>
<p> 2、如果需要写自己的OpenGL代码,那么还是使用Cocos2D,或者其它框架吧,目前Sprite Kit并不支持自定义OpenGL代码。</p>
<p> 3、如果要进行跨平台开发,那么选择Cocos2D-X或者Unity。Cocos2D-X非常出色,可以用它来构建2D游戏。Unity则更加的灵活(例如,如果有需要的话,你可以在游戏中添加一些3D效果)。</p>
<p>看到这里,如果你还想要继续了解Sprite Kit的话,请继续往下读吧。</p>
<h3><strong> Hello,Sprite Kit!</strong></h3>
<p>下面我们就开始利用Xcode 5内置的Sprite Kit模板来构建一个简单的Hello World工程吧。</p>
<p>启动Xcode,选择<code>File\New\Project</code>,接着选中<code>iOS\Application\SpriteKit Game</code>模板,然后单击<code>Next</code>:</p>
<p><img src="http://BeyondVincent.github.io/images/2013/09/7.png"></p>
<p>输入Product Name为<code>SpriteKitSimpleGame</code>,Devices选择iPhone,接着单击<code>Next</code>:</p>
<p><img src="http://BeyondVincent.github.io/images/2013/09/8.png"></p>
<p>选择工程保存的路径,然后点击<code>Create</code>。然后点击Xcode中的播放按钮来运行工程。稍等片刻,可以看到如下运行画面:</p>
<p><img src="http://BeyondVincent.github.io/images/2013/09/9.png"></p>
<p>跟Cocos2D类似,Sprite Kit也是按照<code>场景(scenes)</code>来构建的,这相当于游戏中的”levels”和”screens”。例如,你的游戏中可能会有一个主游戏区的场景,以及一个世界地图的一个场景。</p>
<p>如果你观察一下创建好的工程,会发现SpriteKit Game模板已经创建好了一个默认的场景<code>MyScene</code>。现在打开<code>MyScene.m</code>,里面已经包含了一些代码,其中将一个lable放到屏幕中,并且添加了:当tap屏幕时,会在屏幕上新增一个旋转的飞船。</p>
<p>在本教程中,我们主要在MyScene中写代码。不过在开始写代码之前,需要进行一个小调整——让程序以横屏的方式运行。</p>
<p>……Sprite Kit初级教程(1)结束……</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[iOS 7中的一些小修改]]></title>
<link href="http://BeyondVincent.github.io/blog/2013/09/20/112-ios-7-additions-omg-finally/"/>
<updated>2013-09-20T11:45:00+08:00</updated>
<id>http://BeyondVincent.github.io/blog/2013/09/20/112-ios-7-additions-omg-finally</id>
<content type="html"><![CDATA[<p><img src="http://BeyondVincent.github.io/images/2013/09/4.png"></p>
<h2><strong>小引</strong></h2>
<p>大家都知道iOS 7做了很大的调整,当然也有一些轻微的修改,我们来稍微看一下吧。</p>
<!--more-->
<p>注:本文译自<a href="http://www.doubleencore.com/2013/09/ios-7-additions-omg-finally/"><code>iOS 7 Additions: OMG Finally!</code></a></p>
<h3><strong>目录</strong></h3>
<ul>
<li>Message UI Framework(在消息中添加文件)</li>
<li>Media Player Framework(MPVolumeView – 检测airplay和当前airplay的route)</li>
<li>AVFoundation(条码扫描)</li>
<li>更多</li>
</ul>
<h3><strong> Message UI Framework(在消息中添加文件)</strong></h3>
<p>在iOS 7之前我们可以使用<code>MFMessageComposeViewController</code>来撰写文本消息,但是要想添加文件是不可能做到的,不过在iOS 7中我们可以使用这个方法就能添加文件了:<code>- (BOOL)addAttachmentData:(NSData *)attachmentData typeIdentifier:(NSString *)uti filename:(NSString *)filename;</code>。如下代码示例所示:</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>
<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>
</pre></td><td class='code'><pre><code class=''><span class='line'>if ([MFMessageComposeViewController canSendText] && [MFMessageComposeViewController canSendAttachments] && [MFMessageComposeViewController isSupportedAttachmentUTI:(NSString *)kUTTypePNG]) {
</span><span class='line'> MFMessageComposeViewController *vc = [[MFMessageComposeViewController alloc] init];
</span><span class='line'> vc.messageComposeDelegate = self;
</span><span class='line'> vc.recipients = @[@"Yawkey"];
</span><span class='line'> UIImage *myImage = [UIImage imageNamed:@"Yawkey_business_dog.png"];
</span><span class='line'> BOOL attached = [vc addAttachmentData:UIImagePNGRepresentation(myImage) typeIdentifier:(NSString*)kUTTypePNG filename:@"Yawkey_business_dog.png"];
</span><span class='line'> if (attached) {
</span><span class='line'> NSLog(@"Attached (:");
</span><span class='line'> }
</span><span class='line'> else {
</span><span class='line'> NSLog(@"Not attached ):");
</span><span class='line'> }
</span><span class='line'> [self presentViewController:vc animated:YES completion:nil];
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>
<p><img src="http://BeyondVincent.github.io/images/2013/09/5.png"></p>
<h3><strong> Media Player Framework(MPVolumeView – 检测airplay和当前airplay的route)</strong></h3>
<p><code>MPVolumeView</code>可以帮助我们与AirPlay系统进行交互。不过,一直以来都是很难获得用户选择操作的信息。现在通过新增的两个属性和通知,我们可以更加深入的了解AirPlay系统了。</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>@property areWirelessRoutesAvailable;
</span><span class='line'>@property isWirelessRouteActive;</span></code></pre></td></tr></table></div></figure>
<p>这两个属性可以告诉我们是否有可用的AirPlay,以及是否以及被选中了。下面两个是通知:</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>NSString *const MPVolumeViewWirelessRoutesAvailableDidChangeNotification;
</span><span class='line'>NSString *const MPVolumeViewWirelessRouteActiveDidChangeNotification;</span></code></pre></td></tr></table></div></figure>
<p>通过这两个通知我们可以知道可用AirPlay发生了改变,以及用户修改了当前正在使用的AirPlay route。</p>
<h3><strong>AVFoundation(条码扫描)</strong></h3>
<p><code>AVFoundation</code>中现在已经内置支持一维和二维码的扫描。之前要想在iOS程序中读取条形码和QR码,则需要使用第三方库,例如ZXing和ZBar。在iOS 7中默认支持4中机器条码,需要做的就是将<code>AVCaptureMetadataOutput</code> hook up到<code>AVCaptureSession</code>。另外可以对<code>AVCaptureMetadataOutput</code>进行配置以检测如下这些任意机器可读的条码类型:</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>
<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=''><span class='line'>AVMetadataObjectTypeUPCECode
</span><span class='line'>AVMetadataObjectTypeCode39Code
</span><span class='line'>AVMetadataObjectTypeCode39Mod43Code
</span><span class='line'>AVMetadataObjectTypeEAN13Code
</span><span class='line'>AVMetadataObjectTypeEAN8Code
</span><span class='line'>AVMetadataObjectTypeCode93Code
</span><span class='line'>AVMetadataObjectTypeCode128Code
</span><span class='line'>AVMetadataObjectTypePDF417Code
</span><span class='line'>AVMetadataObjectTypeQRCode
</span><span class='line'>AVMetadataObjectTypeAztecCode</span></code></pre></td></tr></table></div></figure>
<p>当配置好<code>AVCaptureMetadataOutputObjectsDelegate</code>,就可以响应<code>- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection;</code>检测到的所有条码。</p>
<h3><strong>更多</strong></h3>
<p>上面只是列出了少许新内容,你可以通过苹果提供的文档<a href="https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS7.html">What’s New in iOS</a> 查阅更多相关内容。</p>
<p>注:本文是iOS 7开发者指南中的11篇中的第1篇。你可以在<a href="http://www.doubleencore.com/2013/09/essential-ios-7-developers-guide">这里</a>看到指南的全部内容。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Xcode 5中的Interface Builder更有利于团队协作开发]]></title>
<link href="http://BeyondVincent.github.io/blog/2013/09/04/111-xcode-5-finally-makes-interface-builder-a-viable-option-for-teams/"/>
<updated>2013-09-04T11:45:00+08:00</updated>
<id>http://BeyondVincent.github.io/blog/2013/09/04/111-xcode-5-finally-makes-interface-builder-a-viable-option-for-teams</id>
<content type="html"><![CDATA[<h2><strong>小引</strong></h2>
<p>在iOS开发中,开发者有各种理由选择用代码来构建界面,其中最多的理由就是Interface Builder绘制的代码不利于团队间协作(代码的可读性和合并)。虽然Interface Builder来绘制界面有诸多优势,但是由于致命的缺陷,许多开发团队不得不远离它,当然也有一些开发团队为了在协同开发时也使用IB来绘制界面,他们尽量确保同一时期只由一个人来操作某个xib文件,以此避免提交代码的时候需要合并xib文件。然而,在Xcode 5中,苹果的开发团队已经对xib文件格式做了大量的简化工作。本文就来简要的看看相关内容。</p>
<!--more-->
<p>注:本文译自<a href="http://nilsou.com/blog/2013/08/07/xcode-5-finally-makes-interface-builder-a-viable-option-for-teams/"><code>Xcode 5 Finally Makes Interface Builder a Viable Option for Teams</code></a></p>
<h3><strong>目录</strong></h3>
<ul>
<li>Xcode 4中xib文件的格式</li>
<li>Xcode 5中xib文件的格式</li>
<li>小结</li>
</ul>
<p>上周我将代码merge到我的working branch时,注意到以前没曾见过的提示:</p>
<p><img src="http://BeyondVincent.github.io/images/2013/09/1.png"></p>
<p>Git会自动合并<strong>xib文件</strong>!我在想,Xcode 5中肯定对xib文件的格式做了修改,所以我准备深入研究一下。</p>
<p>原来由Xcode 5生成的xib文件是一种全新的格式。看起来苹果这次对xib文件格式的变更将有助于开发团队开始考虑使用IB来绘制界面。</p>
<h3><strong>* Xcode 4中xib文件的格式</strong></h3>
<p>为了演示xib文件格式在Xcode 4和Xcode 5中的差异,我首先在Xcode 4中创建了一个新的xib文件,并添加了一些view进去:一个UIScrollView,该scrollview中包含一些UIButton、UILable和TextView等。</p>
<p><img src="http://BeyondVincent.github.io/images/2013/09/2.png"></p>
<p>然后我在工程导航窗口中右键单击该文件,并选择<code>Open As > Source Code</code>。下面的链接中是看到的内容:</p>
<p><a href="https://gist.github.com/nilsou/6057457">Xcode 4生成的.xib文件</a>(需要点击“File suppressed. Click to show.”)</p>
<p>可以看到,这么简单的一个view居然有<code>1108行</code>代码!这太多了。</p>
<p>对开发者来说它的可读性非常的糟糕。这是开发者为什么不喜欢xib文件的主要原因(由此放弃使用interface builder)。</p>
<p>更糟糕的是这个xib文件的格式还具有不确定性。也就是说如果我在Interface Builder创建相同的UI界面,但是我们看到的文件内容并不是相同的。这就导致xib文件的合并非常的困难,甚至不可能进行合并。这事开发者不使用xib文件的另外一个重要原因。</p>
<h3><strong>* Xcode 5中xib文件的格式</strong></h3>
<p>接着,我在Xcode 5中打开同一个工程。当在Xcode 5中打开用Xcode 4创建的xib文件时,会提示将文件升级到新的格式。这里需要注意的是升级之后的文件只能在Xcode 5中打开,这种新格式的文件不能在老版本中的Xcode中打开。所以,如果是团队协作开发,那么升级的时候,需要确保所有的开发者都使用Xcode 5。</p>
<p><img src="http://BeyondVincent.github.io/images/2013/09/3.png"></p>
<p>我点击<code>Upgrade</code>,然后再次打开xib文件的source code,看看有什么变化。如下链接中所示:</p>
<p><a href="https://gist.github.com/nilsou/6057474">Xcode 5生成的.xib文件</a>(需要点击“File suppressed. Click to show.”)</p>
<p><code>133行</code>!这与Xcode 4中创建的xib文件相差约10倍。可见苹果的开发团队已经对xib文件格式做了大量的简化。</p>
<p>再看看里面的具体内容,可以看出它的可读性也加强了。xib文件中的源代码现在也能够反应出view的层次(Interface Builder左边看到的内容结构!),等熟悉之后,开发者可以直接对这个xml代码进行编写。</p>
<p>最重要的一点,可以看出Xcode 5生成的xib文件内容源码位置是确定的。这非常利于文件的合并。</p>
<h3><strong>小结</strong></h3>
<p>这种新的格式带来的最大好处不仅仅是增强开发者对xib文件的可读性,另外在大多数情况下,git还可以对xib文件进行自动合并,不用开发者手动进行。</p>
<p>现在如果还有开发者告诉你他不想用xib文件,那么请把这篇文章发给他看看吧,我相信已经没有太多理由不使用xib文件了。</p>
<p>其实在Xcode 5中不仅对Interface Builder进行了改善,还有其它一些功能也做了改进,例如自动布局约束的设置已经没有以前痛苦了。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Professional iOS Network Programming翻译第一章:iOS网络功能简介]]></title>
<link href="http://BeyondVincent.github.io/blog/2013/08/09/109-introducing-ios-networking-capabilities/"/>
<updated>2013-08-09T16:52:00+08:00</updated>
<id>http://BeyondVincent.github.io/blog/2013/08/09/109-introducing-ios-networking-capabilities</id>
<content type="html"><![CDATA[<p><img src="http://BeyondVincent.github.io/images/2013/07/simple_social_network.png" width="400" height="300"></p>
<h2><strong>小引</strong></h2>
<p>在iOS开发中,网络是非常重要的功能,针对iOS开发者来说,掌握好iOS中网络功能的开发也是必不可少的。最近在看一本书:<a href="http://www.amazon.com/Professional-iOS-Network-Programming-Connecting/dp/1118362403"><code>Professional iOS Network Programming</code></a>,网络编程方面介绍比较全面,非常适合iOS开发者去读一读,由于精力有限,我在这里可能会挑选一部分内容进行翻译,也有可能全书翻译。</p>
<!--more-->
<h3><strong>目录</strong></h3>
<ul>
<li>Professional iOS Network Programming介绍</li>
<li>第一章:iOS网络功能简介
<ul>
<li>了解网络框架</li>
<li>iOS网络APIs
<ul>
<li>NSURLConnection</li>
<li>Game Kit</li>
<li>Bonjour</li>
<li>NSStream</li>
<li>CFNetwork</li>
<li>BSD Sockets</li>
</ul>
</li>
<li>Run Loops
<ul>
<li>Run Loop模型</li>
</ul>
</li>
<li>小结</li>
</ul>
</li>
</ul>
<h2><strong>Professional iOS Network Programming介绍</strong></h2>
<p>这本书主要介绍在iOS中的网络编程知识,主要包含如下内容:</p>
<pre><code>在客户端和服务器端之间进行HTTP请求
管理客户端和服务器端之间进行的数据负载
处理HTTP请求中的错误
网络通信中的安全
加强网络通信的性能
socket级别的通信
推送通知的实现
同一设备中两个程序间的通信
不同设备中两个程序间的通信
</code></pre>
<h2>第一章:<strong>iOS网络功能简介</strong></h2>
<p>本章的内容</p>
<pre><code>了解iOS网络框架
开发者可用的重要网络APIs
在程序中有效的利用run Loop
</code></pre>
<p>优秀的iOS程序需要简单和直观的用户界面,同样,具有与web service通信功能的优秀程序需要一个良好架构的网络层。在设计应用程序架构时,必须考虑到程序的灵活性,以适应经常变化的需求,并能够正确的处理不断变化的网络条件,同时还需要保持核心设计原则:可维护性和可扩展性。</p>
<p>当在设计移动应用程序的架构时,必须熟悉一些相关的核心概念,例如run loop,可用的网络APIs,以及这些APIs是如何与run loop整合起来实现一个具有响应式的网络应用程序框架。本章详细的探讨了run loop,以及如何在程序中对其有效的使用。同样,也对关键的APIs做了一个概述,并且介绍了什么时候应该使用什么APIs。</p>
<h3><strong>了解网络框架</strong></h3>
<p>在开发iOS应用程序(与网络交互的程序)之前,首先必须理解Objective-C中的网络层是如何组成的,如图1-1所示:</p>
<p><img src="http://BeyondVincent.github.io/images/2013/07/networking_layers_in_OC.jpg"></p>
<p>图1-1</p>
<p>如上图所示,每个iOS应用程序都都位于由四层组成的网络框架之上。最上面的是Cocoa层,该层包含了一些Objective-C写的APIs:<code>URl加载</code>,<code>Bonjour</code>和<code>Game Kit</code>。Cocoa之下是Core Foundation,该层包含了一组C语言写的APIs:<code>CFNetwork</code>,该层中的代码是大量应用层中网络代码的基础。CFNetwork在<code>CFStream</code>和<code>CFSocket</code>之上,提供了一个简单的网络接口。CFStream和CFSocket对BSD socket做了轻量级的封装,BSD是基于硬件上面的一层,它于无线通信相关硬件设备最接近。BSD socket是严格使用C实现的,通过BSD,开发者对网络中的任意通信(远程设备或者服务)拥有绝对控制权。</p>
<p>在上图中,越往下层走,会获得更高的控制权,但是相对于上一层来说易用性更差。苹果建议使用CFNetwork层以及之上的。在BSD层中的raw socket不能访问系统的VPN,也不能激活Wi-Fi或蜂窝无线模块,这些功能是由CFNetwork处理的。</p>
<p>在设计应用程序的网络层之前,开发者必须理解各种可用的APIs。下一节中会介绍iOS中关键的网络框架,并简短的解释一下如何使用它们。在本书后面的章节中,会详细介绍每个APi。</p>
<h3><strong>iOS网络APIs</strong></h3>
<p>在框架中的每层里面,都有一套关键的APIs提供给开发者相关的功能以及控制权。在图1-1中每层相对于下一层,会有更多的封装。不过封装之后,会失去一些控制权。本节就来大概的预览一下iOS中网络层关键的APIs,并探讨一下什么时候使用它们。</p>
<h5>NSURLConnection</h5>
<p>NSURLConnection是Cocoa中的一个API,它提供了一个简单的方法来请求URL,可以与web service进行交互,以获取一个图片或者视频,或者简单的获取一个HTML文档。NSURLConnection构建于NSStream之上,它支持4种通用的URI schemes:file,HTTP,HTTPS和FTP。虽然NSURLConnection限制了可以使用的协议,但是它封装了大量底层API必须要做的任务:对缓冲区进行读写,另外还内置支持认证(authentication),并提供了一个健壮的缓存引擎。</p>
<p>实际上NSURLConnection本身提供的接口比较少,主要依赖于<code>NSURLConnectionDelegate</code>协议,通过该协议,应用程序可以与网络连接生命周期中的多个点进行交互。NSURLConnection的请求默认是异步的;不过也提供了一个同步请求方法。由于同步请求会阻塞当前调用的线程,所以必须根据具体情况来设计应用程序。在第三章(发起请求)中会详细介绍NSURLConnection,并提供了一些示例。</p>
<h6>Game Kit</h6>
<p>在iOS程序中,Game Kit提供了另外一种点对点(peer-to-peer)网络通讯的方法。在传统的网络配置中,Game Kit是构建于Bonjour之上的;不过Game Kit并不需要网络基础设施提供的功能。它可以创建ad-hoc Bluetooth Personal Area Networks(PAN),通过该PAN可以让设备在邻近范围内或网络条件不允许的情况下,进行通讯,</p>
<p>Game Kit只需要一个会话id(session identifier),显示的名称(display name),以及配置网络时的连接模式。不需要配置socket,或其它任意底层网络通讯的连接。Game Kit使用GKSessionDelegate协议进行通讯。在第12章(利用Game Kit进行设备间的通讯)中介绍了将Game Kit集成到我们的程序中。</p>
<h6>Bonjour</h6>
<p><code>Bonjour</code>是苹果实现的零配置联网。Bonjour提供了这样一种机制:发现并连接到设备或者网络中的服务,这些过程中我们并不需要知道设备的网络地址,相反,Bonjour涉及到元祖名称,服务类型和域。Bonjour封装了底层网络接口需要的multicast DNS(mDNS),以及基于DNS服务的发现(DNS-SD)。</p>
<p>在Cocoa层,NSNetService API提供了相关接口用来发布和解决Bonjour服务的地址信息。我们可以使用NSNetServiceBrowser API来发现网络中可用的服务。为了通信,发布一个Bonjour服务,即使是使用Cocoa层的API,也需要明白Core Foundation中对socket的配置。在第13章”Ad-Hoc Networking with Bonjour”中,深入介绍了零配置联网(Bonjour),并给出了一个示例介绍如何实现一个基于Bonjour的服务。</p>
<h6>NSStream</h6>
<p><code>NSStream</code>是Cocoa层里面的API,构建于CFNetwork之上,是NSURLConnection的基础部分,并且还适用于较底层的网络任务。就像NSURLConnection,NSStream提供了一种与远程服务或者本地文件通信的机制。另外,还NSStream还可以在别的一些一些上进行通信,例如<code>telnet</code>,<code>SMTP</code>,NSURLConnection并不支持这些协议。</p>
<p>NSStream还提供了额外的一些控制功能,不过这是要付出代价的。NSStream并没有内置支持处理HTTP/S响应状态码的处理,也不支持认证功能。它是用C缓存器进行数据的发送和接收的,这跟Objective-C还有点区别。它也不能管理多个请求,如果需要相应的功能,需要在其子类中添加功能。NSStream是异步的,它通过NSStreamDelegate进行通信。在第8章中“Low-Level Networking”,以及第13章中“Ad-Hoc Networking with Bonjour”,都不同程度的实现了NSStream。</p>
<h6>CFNetwork</h6>
<p><code>CFNetwork API</code>构建于BSD socket之上,被用于NSStream、URL加载系统、Bonjour和Game Kit APIs的实现中。CFNetwork中默认支持一些上层协议,例如HTTP和FTP。CFNetwork和BSD socket最关键的区别就是集成了run loop。如果在程序中使用了CFNetwork,输入(input)和输出(output)事件会在线程的run loop中被调度。如果输入和输出事件发生于非主线程上,那么我们需要负责在这个线程中以适当的模式启动run loop。本章后面的“Run Loops”小节会有相关介绍。</p>
<p>CFNetwork提供的配置选项要比URL加载系统更多,这有好的一面,也有不好的一面。当利用CFNetwork创建一个HTTP请求时,这些配置选项是可见的。在创建请求的时候必须手动添加所有的HTTP header,以及cookies,然后与请求一起提交。而使用NSURLConnection时,标准的header和cookie jar中的任意cookies都自动的添加好了。</p>
<p>CFNetwork下面还有来自Core Foundation层中的CFSocket和CFStream APIs。CFNetwork中有一些用于特定协议的APIs,例如用于与FTP服务通讯的CFFTP,用于收发HTTP消息的CFHTTP,以及用于发布和浏览Bonjour服务的CFNetServices。第八章中将详细介绍CFNetwork,而在13章中会简要介绍一下Bonjour。</p>
<h6>BSD Sockets</h6>
<p>在网络架构中,<code>BSD Sockets</code>为网络通信提供了最基础的服务,也是最底层的一个APIs。BSD Socket是用C语言实现的,不过完全可以用在Objective-C代码中。一般不建议直接使用BSD Socket API,因为它在操作系统中没有任何hook。例如,BSD Socket既不走系统中的VPN通道,也没相关的API来自动激活已经关闭掉的Wi-Fi或蜂窝无线设备。苹果建议编程时使用CFNetwork或更高的层中的API。第8章中详细介绍了BSD Sockets以及CFNetwork,并提供了一个示例介绍了如何将它们集成到程序中。下一节将讨论run loop——从操作系统中检测网络事件,这些事件会被用于我们的程序中。</p>
<h3><strong>Run Loops</strong></h3>
<p>Run loop对应的类是<code>NSRunLoop</code>,它其实是线程中的一个基础组件,有了run loop之后,操作系统就能够唤醒休眠中的线程,以对即将到来的事件进行管理。一个run loop是一个循环配置的用来调度任务,并在一个时钟周期内处理即将到来的事件。在iOS程序中的每个线程中最多能有一个run loop。主线程中的run loop在程序启动的时候就默认开启了,并且当程序的delegate applicationDidFinishLaunchingWithOptions:被调用之后,我们就可以对其进行访问了。</p>
<p>在非主线程中,如果需要使用run loop,需要开发者明确的开启run loop。在非主线程中启动之前,必须添加一个输入源(input source)或者timer;否则run loop会立即退出。run loop给开发者提供了与线程交互的能力,不过并不是总是需要它的。例如有时候线程在处理大量数据时,并不不需要进行任何交互,此时就不需要启动run loop了。如果线程需要跟网络进行交互,此时就需要启动run loop。</p>
<p>Run loop接收的事件有两种源类型:输入源<code>(input sources)</code>和<code>计时器(timers)</code>。在输入源中一般要么是基于端口的,要么就是自定义的,这些事件通过异步的方式派发到程序中。这两种类型源的最大区别就是基于端口的内核信号源是自动的,而自定义的源必须在不同线程中手动管理相关信号。在创建自定义输入源时,可以通过CFRunLoopSourceRef实现多个回调函数。</p>
<p>计时器则是这样一种机制:基于时间进行通知应用程序在未来某个特定时间点执行某个特定的任务的。计时器事件也是通过异步的方式派发到程序中的,不过它还与特定的模式相关(下一节将介绍相关模式)。如果并不是当前监听的特定模式,这个计时器时间会被忽略,而线程也不会受到通知,直到run llop运行在相应的模式中。</p>
<p>翻译比较辛苦,下面给大家留点作业,让大家感受一下翻译吧。</p>
<p>You can configure timers to fire once or repeatedly. Rescheduling is based on the scheduled fire time, not the actual fire time. If a timer fires while the run loop is executing an application handler method, it waits until the next pass through the run loop to call the timer handler, typically set via @selector(). If firing the handler is delayed to the point in which the next invocation occurs, the timer fires only one event with the delayed event being suppressed.
Run loops can also have observers, which are not monitored and provide a way for objects to receive callbacks as certain activities in the run loop execution occur. These activities include when the run loop is entered or exited, as the run loop goes to sleep or wakes up, and before the run loop processes an input source or timer. They are documented in the CFRunLoopActivity enumeration. Observers can be configured to fire once, which removes the observer after ithas been fired, or repeatedly. To add a run loop observer, use the Core Foundation function CFRunLoopObserverRef().</p>
<h4>Run Loop模型</h4>
<p>Each pass through the run loop is run in a specific mode specified by you. Run loop modes are a convention used by the operating system to filter the sources that are monitored and allowed to deliver events, such as calling a delegate method. Modes include the input sources and timers that should be monitored as well as any observers that should be notified of run loop events.
There are two predefined run loop modes in iOS. NSDefaultRunLoopMode (kCFRunLoopDefaultMode in Core Foundation) is the system default and should typicallybe used when starting run loops and configuring input sources.
NSRunLoopCommonModes (kCFRunLoopCommonModes in Core Foundation) is a collection of modes that is configurable. Assigning NSRunLoopCommonModes to an input source by calling a method such as scheduleInRunLoop:forMode: on an input source instance associates it with all modes currently in the group.
Although NSRunLoopCommonModes is configurable, it is a low-level process that requires calling the Core Foundation function CFRunLoopAddCommonMode(). This automatically registers input sources, timers, and observers with the new mode instead of manually adding them to each new mode. You can define custom run loop modes by specifying a custom string such as @“CustomRunLoopMode”. For your custom run loop to be effective, you must add at least one input source, timer, or observer.
Although this provides an overview of run loops, Apple provides several in-depth resources onrun loop management that you should review if you develop advanced, network-based, and multi- threaded applications. The developer documentation is available at <a href="https://developer.apple">https://developer.apple</a> .com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/ RunLoopManagement.html. Networking techniques that benefit from run loop integration are discussed in their respective chapters such as Chapter 8, “Low-Level Networking” and Chapter 13, “Ad-Hoc Networking with Bonjour.</p>
<p>相关更多资料请看这里:<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html"><code>RunLoopManagement</code></a></p>
<h3><strong>小结</strong></h3>
<p>对于iOS开发者来说,理解iOS网络框架中的各层,以及应用程序如何与run loop交互是非常重要的。一个优秀的网络架构层会给应用程序提供难以置信的灵活度。如果网络架构层的设计非常糟糕,那么这是很难获得成功和扩展能力的。</p>
<p>本章预览了一下各个网络APIs,并做了一些比较。在这里只是简单的介绍了一下,在后续章节中,会深入讨论。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[利用Octopress搭建一个Github博客]]></title>
<link href="http://BeyondVincent.github.io/blog/2013/08/03/108-creating-a-github-blog-using-octopress/"/>
<updated>2013-08-03T13:38:00+08:00</updated>
<id>http://BeyondVincent.github.io/blog/2013/08/03/108-creating-a-github-blog-using-octopress</id>
<content type="html"><![CDATA[<p><img src="http://BeyondVincent.github.io/images/2013/08/github_page_and-octopress.png"></p>
<h2>小引</h2>
<p><a href="http://octopress.org/"><code>Octopress</code></a>是利用<a href="http://github.com/mojombo/jekyll"><code>Jekyll</code></a>博客引擎开发的一个博客系统,生成的静态页面能够很好的在github page上展现。号称是hacker专属的一个博客系统(<code>A blogging framework for hackers.</code>)</p>
<p>根据大家的反应,本文我就来介绍一下如何在苹果电脑(OS X 10.8.3)利用Octopress搭建一个Github博客。本文需要读者熟悉一些shell命令,并掌握基本的git操作。</p>
<!--more-->
<h3>目录</h3>
<ul>
<li>1、安装Ruby</li>
<li>2、安装Octopress</li>
<li>3、配置Octopress</li>
<li>4、将博客部署到GitHub上</li>
<li>5、开始写博客</li>
<li>6、更多操作</li>
<li>7、小结</li>
</ul>
<h3>1、安装Ruby</h3>
<p>Octopress需要Ruby环境,RVM(Ruby Version Manager)负责安装和管理Ruby的环境。所以我们先在终端输入如下命令,来安装RVM:</p>
<figure class='code'><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=''><span class='line'>curl -L https://get.rvm.io | bash -s stable --ruby</span></code></pre></td></tr></table></div></figure>
<p>接着是安装Ruby 1.9.3,在终端依次运行如下命令:</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>rvm install 1.9.3
</span><span class='line'>rvm use 1.9.3
</span><span class='line'>rvm rubygems latest</span></code></pre></td></tr></table></div></figure>
<p>完成上面的操作之后,运行<code>ruby --version</code>应该可以看到ruby 1.9.3环境已经安装好了。</p>
<p>参考:<a href="http://octopress.org/docs/setup/rvm/">Installing Ruby With RVM</a></p>
<h3>2、安装Octopress</h3>
<p>在安装Octopress之前,请确保你的电脑上已经安装有git了,在终端输入<code>git --version</code>,应该可以看到电脑中的git版本(我电脑上输出:<code>git version 1.7.12.4 (Apple Git-37)</code>),如果没有显示相关内容,请先安装<a href="http://git-scm.com/">git</a>。</p>
<p>git安装之后,利用git命令将octopress从github上clone到本机,如下命令:</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>git clone git://github.com/imathis/octopress.git octopress
</span><span class='line'>cd octopress # If you use RVM, You'll be asked if you trust the .rvmrc file (say yes).
</span><span class='line'>ruby --version # Should report Ruby 1.9.3</span></code></pre></td></tr></table></div></figure>
<p>接着安装相关依赖项:</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>gem install bundler
</span><span class='line'>rbenv rehash # If you use rbenv, rehash to be able to run the bundle command
</span><span class='line'>bundle install</span></code></pre></td></tr></table></div></figure>
<p>最后安装默认的Octopress 主题。</p>
<figure class='code'><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=''><span class='line'>rake install</span></code></pre></td></tr></table></div></figure>
<p>参考: <a href="http://octopress.org/docs/setup/">Octopress Setup</a></p>
<h3>3、配置Octopress</h3>
<p>Octopress的作者已经尽量让配置简化了。大多数情况下只需要配置<code>_config.yml</code>和<code>Rakefile</code>文件即可。其中Rakefile是跟博客部署相关,一般情况下并不需要修改这个文件,除非使用了rsync。</p>
<p><em>config.yml是博客重要的一个配置文件,在</em>config.yml文件中有三大配置项:<code>Main Configs</code>、<code>Jekyll & Plugins</code>和<code>3rd Party Settings</code>。</p>
<p>一般,该文件中其中<code>url</code>是必须要填写的,这里的url是在github上创建的一个仓库地址,具体请看第四步中创建的地址。另外再修改一下<code>title</code>、<code>subtitle</code>和<code>author</code>,根据需求,在开启一些第三方组件服务。</p>
<p>关于_config.yml文件中的更多内容,请看这里的内容:<a href="http://octopress.org/docs/configuring/">Configuring Octopress</a></p>
<p>建议:最好把里面的twitter相关的信息全部删掉,否则由于GFW的原因,将会造成页面load很慢。同理,修改定制文件/source/_includes/custom/head.html 把google的自定义字体去掉。from<a href="http://blog.devtang.com/blog/2012/02/10/setup-blog-based-on-github/"><code>唐巧的博文中—配置</code></a>。</p>
<h3>4、将博客部署到GitHub上</h3>
<p>Github的<a href="http://pages.github.com/"><code>Page service</code></a>可以免费托管博客,并且还可以自定义域名。</p>
<p>首先需要在GitHub上<a href="https://github.com/new"><code>创建一个仓库</code></a>,并将仓库名称按照这样的方式进行命名:<code>username.github.com</code>或<code>organization.github.com</code>。等后面配置完毕之后,我们就可以在浏览器中使用页面地址<code>http://username.github.com</code>来访问我们的博客。一般来说,我们希望在将博客的源码放到source分支下,并把生成的内容提交到master分支。</p>
<p>创建好仓库之后,我们需要利用octopress的一个<code>配置rake任务</code>来自动配置上面创建的仓库:可以让我们方便的部署GitHub page。在终端输入如下命令:</p>
<figure class='code'><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=''><span class='line'>$ rake setup_github_pages</span></code></pre></td></tr></table></div></figure>
<p>上面的命令会做一些事情(详细介绍看下面给出的参考链接)。其中最主要的就是创建一个<code>_deploy</code>目录,目录用来存放部署到master分支的内容。期间会要求你输入仓库的url,根据提示,进行输入即可。</p>
<p>完成上面的命令之后,我们就可以生成博客并真正的部署到仓库中了。执行如下命令:</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>rake generate
</span><span class='line'>rake deploy</span></code></pre></td></tr></table></div></figure>
<p>上面的命令首先生成博客文件,并将生成的博客文件拷贝到<code>_deploy/</code>目录下,然后将这些内容添加到git中,并commit和push到仓库的master分支。</p>
<p>现在可以访问<code>http://username.github.com</code>了。注意:有时候可能会有延时,要等几分钟才能打开。</p>
<p>至此,我们的博客已经完成基本的部署,不过博客的source需要单独提交,执行如下命令就可以将source提交到仓库的source分支下。</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ git add .
</span><span class='line'>$ git commit -m 'Initial source commit'
</span><span class='line'>$ git push origin source</span></code></pre></td></tr></table></div></figure>
<p>如果在部署到仓库之前,需要先预览一下博客,可以在终端输入<code>rake preview</code>命令,然后就能在浏览器中进行本地预览访问了:<code>http://127.0.0.1:4000/</code>或<code>http://localhost:4000/</code>,效果跟仓库中的一样。</p>
<p>参考:<a href="http://octopress.org/docs/deploying/">Deploying to Github Pages</a></p>
<h3>5、开始写博客</h3>
<p>Octopress为我们提供了一些task来创建博文和页面。博文必须存储在<code>source/_posts</code>目录下,并且需要按照Jekyll的命名规范对文章进行命名:<code>YYYY-MM-DD-post-title.markdown</code>。文章的名字会被当做url的一部分,而其中的日期用于对博文的区分和排序。</p>
<p>通过Octopress提供的task可以正确的按照命名规范创建一个博文,并且在博文中会附带常用的一些yaml元数据。只需要在终端输入如下命令:</p>
<figure class='code'><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=''><span class='line'>rake new_post["title"]</span></code></pre></td></tr></table></div></figure>
<p>其中title为博文的文件名,创建出来的文件默认是markdown格式。上面的命令会创建出这样一个文件:<code>source/_posts/2013-08-03-title.markdown</code>。打开这个文件,可以看到里面有如下一些内容了(告诉Jekyll博客引擎如何处理博文和页面):</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'>---
</span><span class='line'>layout: post
</span><span class='line'>title: "title"
</span><span class='line'>date: 2013-08-03 16:36
</span><span class='line'>comments: true
</span><span class='line'>categories:
</span><span class='line'>---</span></code></pre></td></tr></table></div></figure>
<p>接着我们就可以在这个文件中写我们的博文啦。完成之后,我们可以预览和部署博文。下面是创建并部署博文的一个完整过程:</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ rake new_post["New Post"]
</span><span class='line'>$ rake generate
</span><span class='line'>$ git add .
</span><span class='line'>$ git commit -am "Some comment here."
</span><span class='line'>$ git push origin source
</span><span class='line'>$ rake deploy</span></code></pre></td></tr></table></div></figure>
<p>参考:<a href="http://octopress.org/docs/blogging/">Blogging Basics</a></p>
<h3>6、更多操作</h3>
<p>在搭建博客的时候,我们可能会对博客做一些配置,例如添加评论、域名解析、分享等。这些内容我写在另外一篇文章中,会经常更新,请前往观看:<a href="http://beyondvincent.com/blog/2013/07/27/107-hello-page-of-github/"><code>你好!github页面</code></a>。</p>
<h3>7、小结</h3>
<p>本文介绍了如何利用Octopress搭建一个Github博客。大家在搭建的时候,要是遇到问题,可以回复我。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[你好!github页面]]></title>
<link href="http://BeyondVincent.github.io/blog/2013/07/27/107-hello-page-of-github/"/>
<updated>2013-07-27T14:44:00+08:00</updated>
<id>http://BeyondVincent.github.io/blog/2013/07/27/107-hello-page-of-github</id>
<content type="html"><![CDATA[<p><img src="http://BeyondVincent.github.io/images/2013/07/wordpress_to_octopress.png"></p>
<h3>大家好,我是破船!欢迎大家关注我的小站!</h3>
<p>我写博文经历了这些平台:
百度空间-><a href="http://www.devdiv.com/home.php?mod=space&uid=12&do=blog&view=me&from=space"><code>devdiv</code></a>><a href="http://blog.sina.com.cn/beyondvincent"><code>新浪博客</code></a>–><a href="http://blog.csdn.net/beyondvincent"><code>CSDN</code></a>–><code>wordpress</code>–><code>octopress</code>(现在)</p>
<!--more-->
<p>用wordpress搭建的博客,用了4个月,由于有好多麻烦事(备份、空间和流量等各种不爽),现在果断在github上配合octopress搭建一个博客。</p>
<p>由于<code>git</code>和<a href="http://en.wikipedia.org/wiki/Markdown"><code>markdown</code></a>对我来说就是小白,所以搭建的时间断断续续持续了约一周。其实网上已经有很好的参考资料了,只要照着弄,很容易就能搭建好的。</p>
<p>这篇文章是第一篇,我用的markdown编辑器是<a href="http://mouapp.com/"><code>Mou</code></a>,感觉不错。</p>
<p>下面是一些在mac机器上用octopress写博文需要用到的操作(持续更新)</p>
<h3>目录</h3>
<ul>
<li>发表并部署博文</li>
<li>添加多说评论功能</li>
<li>起草文章 暂不公开</li>
<li>域名解析</li>
<li>添加百度统计和google analytics</li>
</ul>
<h3>发表并部署博文</h3>
<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>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ rake new_post["New Post"]
</span><span class='line'>$ rake generate
</span><span class='line'>$ git add .
</span><span class='line'>$ git commit -am "Some comment here."
</span><span class='line'>$ git push origin source
</span><span class='line'>$ rake deploy</span></code></pre></td></tr></table></div></figure>
<h3>添加多说评论功能</h3>
<h4>A 获取<code>short_name</code></h4>
<p>去多说网注册账号,获取站点的short_name</p>
<h4>B 在<code>_config.yml</code>文件中添加如下内容</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>
</pre></td><td class='code'><pre><code class=''><span class='line'># duoshuo comments
</span><span class='line'>duoshuo_comments: true
</span><span class='line'>duoshuo_short_name: yourname</span></code></pre></td></tr></table></div></figure>
<h4>C 在<code>source/_layouts/post.html</code>中添加多说评论模块</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>{% if site.duoshuo_short_name and site.duoshuo_comments == true and page.comments == true %}
</span><span class='line'> <section>
</span><span class='line'> <h1>Comments</h1>
</span><span class='line'> <div id="comments" aria-live="polite">{% include post/duoshuo1.html %}</div>
</span><span class='line'> </section>
</span><span class='line'>{% endif %}</span></code></pre></td></tr></table></div></figure>
<h4>D 创建<code>source/_includes/post/duoshuo.html</code>,并填入如下内容</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>
</pre></td><td class='code'><pre><code class=''><span class='line'><!-- Duoshuo Comment BEGIN -->
</span><span class='line'><div class="ds-thread"></div>
</span><span class='line'><script type="text/javascript">
</span><span class='line'> var duoshuoQuery = {short_name:"beyondvincent"};
</span><span class='line'> (function() {
</span><span class='line'> var ds = document.createElement('script');
</span><span class='line'> ds.type = 'text/javascript';ds.async = true;
</span><span class='line'> ds.src = 'http://static.duoshuo.com/embed.js';
</span><span class='line'> ds.charset = 'UTF-8';
</span><span class='line'> (document.getElementsByTagName('head')[0]
</span><span class='line'> || document.getElementsByTagName('body')[0]).appendChild(ds);
</span><span class='line'> })();
</span><span class='line'></script>
</span><span class='line'><!-- Duoshuo Comment END --></span></code></pre></td></tr></table></div></figure>
<h4>E 发布到站点</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>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ rake generate
</span><span class='line'>$ git add .
</span><span class='line'>$ git commit -am "添加多说评论"
</span><span class='line'>$ git push origin source
</span><span class='line'>$ rake deploy</span></code></pre></td></tr></table></div></figure>
<h3>起草文章暂不公开</h3>
<p>在文章头部添加<code>published: false</code>,就能起到暂时不公开文章了(即使已经部署到了github中),要公开文章只需要将false修改<code>true</code>即可。</p>
<h3>域名解析</h3>
<p>我们可以给GitHub上的page指定一个域名,具体做法如下2个步骤</p>
<h4>1、给repo配置域名</h4>
<p>在<code>source</code>根目录下新建一个名为CNAME的文件,并把你的域名填写进去,例如<code>beyondvincent.com</code>。这样做的目的是告诉GitHub服务器开始将repo中的page(例如<code>beyondvincent.github.io</code>)指向到某个域名中。</p>
<h4>2、配置DNS(我的域名是在godaddy上购买的)</h4>
<p>添加一条A记录:
<code>@ 204.232.175.78</code>
在CNAME中添加一条记录:
<code>http beyondvincent.github.com</code></p>
<h3>添加百度统计和google analytics</h3>
<p>从百度统计获取脚本,然后添加到文件<code>source/_includes/after_footer.html</code>文件中
从google analytics获取跟踪ID,然后将这个ID添加到<code>_config.yml</code>文件的<code>google_analytics_tracking_id</code>后面即可。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Mac和iOS开发资源汇总—更新于2013-08-19]]></title>
<link href="http://BeyondVincent.github.io/blog/2013/07/18/106/"/>
<updated>2013-07-18T00:00:00+08:00</updated>
<id>http://BeyondVincent.github.io/blog/2013/07/18/106</id>
<content type="html"><![CDATA[<p><a href="http://beyondvincent.com/wp-content/uploads/2013/07/1U55JG9-0.jpg"><img class="alignnone size-full wp-image-1661" alt="1U55JG9-0" src="http://beyondvincent.com/wp-content/uploads/2013/07/1U55JG9-0.jpg" width="590" height="578" /></a></p>
<h2><strong><span style="color: #339966;">小引</span></strong></h2>
<p>本文主要汇集一些苹果开发的资源,会经常更新,建议大家把这篇文章单独收藏(在浏览器中按<strong><span style="color: #339966;">command+D</span></strong>)。</p>
<!--more-->
<p>今天(2013年7月19日)收录了许多中文网站和博客。大家一定要去感受一下哦。</p>
<p>如果大家有知道不错的站点,可以告诉我。</p>
<p> </p>
<h2><strong><span style="color: #339966;">目录</span></strong></h2>
<p><strong><span style="color: #339966;">1、苹果官方文档</span></strong><br/>
<strong><span style="color: #339966;"> 2、邮件列表</span></strong><br/>
<strong><span style="color: #339966;"> 3、论坛</span></strong><br/>
<strong><span style="color: #339966;"> 4、网站</span></strong><br/>
<strong><span style="color: #339966;"> 5、博客</span></strong><br/>
<strong><span style="color: #339966;"> 6、大会</span></strong><br/>
<strong><span style="color: #339966;"> 7、播客和录像</span></strong></p>
<h3><strong><span style="color: #339966;">正文</span></strong></h3>
<h2><strong><span style="color: #339966;">1、苹果官方文档</span></strong></h2>
<p>构建iOS程序:下面的这篇文章介绍了 iOS 程序开发的过程:<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="https://developer.apple.com/library/ios/#referencelibrary/GettingStarted/RoadMapiOS/chapters/RM_YourFirstApp_iOS/Articles/01_CreatingProject.html" target="_blank"><span style="color: #339966; text-decoration: underline;">Start Developing iOS Apps Today</span></a></span></span></strong></p>
<p>构建Mac OS X程序:下面这篇文章介绍了Mac OS X开发的过程:<br/>
<span style="color: #339966;"><strong><span style="text-decoration: underline;"><span style="text-decoration: underline;"><a href="https://developer.apple.com/library/mac/#referencelibrary/GettingStarted/RoadMapOSX/chapters/01_Introduction.html" target="_blank"><span style="color: #339966; text-decoration: underline;">Start Developing Mac Apps Today</span></a></span></span></strong></span></p>
<p>Objective-C:下面的这个链接是苹果官方介绍Objective-C的文档:<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html" target="_blank"><span style="color: #339966; text-decoration: underline;">Programming with Objective-C</span></a></span></span></strong></p>
<p>Xcode:下面这个链接是苹果官方介绍Xcode用户指南。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode_User_Guide/000-About_Xcode/about.html" target="_blank"><span style="color: #339966; text-decoration: underline;">Xcode User Guide</span></a></span></span></strong></p>
<h2></h2>
<h2><strong><span style="color: #339966;">2、邮件列表</span></strong></h2>
<p>Cocoa-dev:由苹果负责运维,最初内容是与Mac OS X 中的Cocoa相关,目前在这个list上的许多开发者可以帮助你解决 iOS 相关问题(提问的时候最好先搜索一下,之前是否有人提问过相关问题)。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="https://lists.apple.com/mailman/listinfo/cocoa-dev" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="https://lists.apple.com/mailman/listinfo/cocoa-dev">https://lists.apple.com/mailman/listinfo/cocoa-dev</a></span></a></span></span></strong></p>
<p>Xcode-user:由苹果负责运维,该邮件列表是跟Xcode相关:<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="https://lists.apple.com/mailman/listinfo/xcode-users" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="https://lists.apple.com/mailman/listinfo/xcode-users%C2%A0">https://lists.apple.com/mailman/listinfo/xcode-users%C2%A0</a></span></a></span></span></strong></p>
<p>Quartz-dev: 有苹果负责运维,该邮件列表主要是讨论Quartz 2D和Core Graphics相关技术:<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://lists.apple.com/mailman/listinfo/quartz-dev" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://lists.apple.com/mailman/listinfo/quartz-dev">http://lists.apple.com/mailman/listinfo/quartz-dev</a></span></a></span></span></strong></p>
<p>iPhone SDK开发:这是第三方的一个邮件列表,主要讨论 iOS 开发。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://groups.google.com/group/iphonesdkdevelopment" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://groups.google.com/group/iphonesdkdevelopment">http://groups.google.com/group/iphonesdkdevelopment</a></span></a></span></span></strong></p>
<p> </p>
<h2><strong><span style="color: #339966;">3、论坛</span></strong></h2>
<p><strong><span style="color: #ff0000;">英文</span></strong></p>
<p>Learn Cocoa Forum:该论坛是书籍Learn cocoa on the Mac and Beginning iOS Development的官方论坛。活跃度非常不错,有初学者,也有经验丰富的开发者。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://forum.learncocoa.org/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://forum.learncocoa.org/">http://forum.learncocoa.org/</a></span></a></span></span></strong></p>
<p>Cocoa Cafe:这是法国的一个论坛(主要是法语)<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://www.cocoacafe.fr" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.cocoacafe.fr">http://www.cocoacafe.fr</a></span></a></span></span></strong></p>
<p>Apple Developer Forums:这是苹果官方的开发者社区,主要讨论 iOS 和Mac软件开发。许多 iOS 开发初学者和有经验的人(包括苹果的工程师和步道师),都经常为这个论坛做着贡献。在这里是预发布版的SDK(在NDA限制下)是唯一可以合法讨论的地方。要访问该论坛,需要注册一个Apple ID。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://devforums.apple.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://devforums.apple.com/">http://devforums.apple.com/</a></span></a></span></span></strong></p>
<p>Apple Discussions,Developer Forums:这是苹果的社区论坛(针对Mac和iOS软件开发者):<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="https://discussions.apple.com/community/developer_forums?categoryID=164" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="https://discussions.apple.com/community/developer_forums?categoryID=164">https://discussions.apple.com/community/developer_forums?categoryID=164</a></span></a></span></span></strong></p>
<p>Apple Discussions,iPhone:这是讨论iPhone的苹果社区论坛<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="https://discussions.apple.com/community/iphone?categoryID=201" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="https://discussions.apple.com/community/iphone?categoryID=201%C2%A0">https://discussions.apple.com/community/iphone?categoryID=201%C2%A0</a></span></a></span></span></strong></p>
<p> </p>
<p><strong><span style="color: #ff0000;">中文</span></strong></p>
<p>CocoaChina:CocoaChina创立于2008年3月,是一个苹果产品和 iOS 开发的中文社区网站,主要为苹果产品开发者提供资讯、信息及服务。<br/>
<span style="text-decoration: underline; color: #339966;"><strong><span style="text-decoration: underline;"><a href="http://www.cocoachina.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.cocoachina.com/">http://www.cocoachina.com/</a></span></a> </span></strong></span></p>
<p>DevDiv:国内早期比较流行的一个移动开发者社区之一,涉猎 iOS、Android和Windows Phone等各移动平台开发。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://www.devdiv.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.devdiv.com/">http://www.devdiv.com/</a></span></a></span></span></strong></p>
<p>泰然网:成立于2011年9月,由泰然翻译团队,泰然技术团队,泰然管理团队组成。翻译了大量国外优秀文章,同时也有许多经典原创。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://www.ityran.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.ityran.com/">http://www.ityran.com/</a></span></a></span></span></strong></p>
<p>Cocos2d-x:Cocos2d-x 是一个开源的支持多平台的 2D 手机游戏引擎。国内难得的一个优秀开源项目。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://www.cocos2d-x.org/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.cocos2d-x.org/">http://www.cocos2d-x.org/</a></span></a></span></span></strong></p>
<p> </p>
<h2><strong><span style="color: #339966;">4、网站</span></strong></h2>
<p><span style="color: #ff0000;"><b>英文</b></span></p>
<p>github:当下最牛叉的开源代码库和版本控制系统。<br/>
<span style="color: #339966;"><strong><span style="text-decoration: underline;"><span style="text-decoration: underline;"><a href="https://github.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="https://github.com/">https://github.com/</a></span></a></span></span></strong></span></p>
<p>Stack Overflow:这是针对程序员的社区问答网站。许多有经验的iOS程序员会常驻这里回答问题:<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/">http://stackoverflow.com/</a></span></a></span></span></strong></p>
<p>除了访问Stack Overflow主站以外,还可以使用标签来浏览iOS开发的相关主题:<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/questions/tagged/objective-c" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/questions/tagged/objective-c">http://stackoverflow.com/questions/tagged/objective-c</a></span></a></span></span></strong><br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/questions/tagged/iphone" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/questions/tagged/iphone">http://stackoverflow.com/questions/tagged/iphone</a></span></a></span></span></strong><br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/questions/tagged/xcode" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/questions/tagged/xcode">http://stackoverflow.com/questions/tagged/xcode</a></span></a></span></span></strong><br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/questions/tagged/ios" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://stackoverflow.com/questions/tagged/ios">http://stackoverflow.com/questions/tagged/ios</a></span></a></span></span></strong></p>
<p>maniacdev:该站点是由软件开发者Johann Dowa维护。内容主要包括:iOS 程序开发库、控件、教程、示例和工具。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://maniacdev.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://maniacdev.com/">http://maniacdev.com/</a></span></a></span></span></strong></p>
<p>Cocoa Controls:在这个站点可以找到许多免费并开源的GUI组件(包括iOS和Mac OS)。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://cocoacontrols.com" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://cocoacontrols.com">http://cocoacontrols.com</a></span></a></span></span></strong></p>
<p>NSHipster: 这个站点介绍Objective-C和Cocoa的相关内容。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://nshipster.com" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://nshipster.com">http://nshipster.com</a></span></a></span></span></strong></p>
<p>iOS Fonts:详细列出了iOS中可用的字体。可以选择不同 iOS 版本支持的字体。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://iosfonts.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://iosfonts.com/">http://iosfonts.com/</a></span></a></span></span></strong></p>
<p>Cocoa Dev Central:从2001年以来,该站点就是Mac OS X编程中最流行的站点之一。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://cocoadevcentral.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://cocoadevcentral.com/">http://cocoadevcentral.com/</a></span></a></span></span></strong></p>
<p>cocoanetics: 网站负责人号称天生就是写Objective-C的,里面的文章更新频率也比较快,好多内容(例如Core data)的介绍都比较深入,值得关注。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://www.cocoanetics.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.cocoanetics.com/">http://www.cocoanetics.com/</a></span></a></span></span></strong></p>
<p> </p>
<p><strong><span style="color: #ff0000;">中文</span></strong></p>
<p>iOS Feed:该站点由许小帅负责维护,许小帅目前任职于腾讯。iOS Feed汇集了许多优秀的iOS开发文章,经常会有新的更新。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://iosfeed.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://iosfeed.com/">http://iosfeed.com/</a></span></a></span></span></strong></p>
<p>Code4App:code4app是一个移动平台的代码库,目前收集了iOS平台几百个代码,并且配有效果图和演示视频。<br/>
<span style="text-decoration: underline;"><span style="color: #339966;"><strong><a href="http://code4app.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://code4app.com/">http://code4app.com/</a></span></a></strong></span></span></p>
<p>UI4APP:收集了许多iOS应用的截图,并进行分类浏览,方便美工设计找素材、找灵感。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://ui4app.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://ui4app.com/">http://ui4app.com/</a></span></a></span></span></strong></p>
<p>苹果核:该站点由多人一起维护,其中一名是来自天猫的高嘉峻。苹果核主要探讨开发ios开发,介绍mac os应用,谈论apple产品发展,关注apple相关的一切。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://pingguohe.net/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://pingguohe.net/">http://pingguohe.net/</a></span></a></span></span></strong></p>
<p> </p>
<h2><strong><span style="color: #339966;">5、博客</span></strong></h2>
<p><strong><span style="color: #ff0000;">英文</span></strong></p>
<p>Matt Gemmell的博客:Matt对Objective-C 开发拥有丰富的经验和观点,这些观点非常值得我们去关注<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://www.mattgemmell.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.mattgemmell.com/">http://www.mattgemmell.com/</a></span></a></span></span></strong></p>
<p>Cocoa is my Girlfriend:这是有Marcus Zarra带领的一批博客,主要集中在iOS和Cocoa开发的问题上。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://cimgf.com" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://cimgf.com">http://cimgf.com</a></span></a></span></span></strong></p>
<p>Ray Wenderlich的博客:实际上Ray站点发展到现在,已经非常的庞大,感觉有点不想博客了,不过还是将其列在博客范围内。对于iOS开发者这个站点提供了非常好的资源,涉及的主题也非常广泛。虽然许多内容是针对游戏开发者的,但是在这个站你总能发现感兴趣的东西。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://www.raywenderlich.com" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.raywenderlich.com">http://www.raywenderlich.com</a></span></a></span></span></strong></p>
<p>Wolf Rentzsch的博客:Wolf是一个有丰富经验的Cocoa独立开发者,也是C4独立开发者大会(现在已经解散)的创始人。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://rentzsch.tumblr.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://rentzsch.tumblr.com/">http://rentzsch.tumblr.com/</a></span></a></span></span></strong></p>
<p>iDevblogaDay:这是一个有多个作者贡献的博客,阅读这里的内容,会从不同的开发者者身上发现新的见解。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://idevblogaday.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://idevblogaday.com/">http://idevblogaday.com/</a></span></a></span></span></strong></p>
<p>Wil Shipley的博客:在这个星球上,Wil是一个拥有丰富Objective-C开发经验的程序员。他博客中的<strong><em><span style="color: #339966;">Pimp My Code</span></em></strong>系列文章是每一个Objective-C程序都应该阅读的。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://blog.wilshipley.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://blog.wilshipley.com/">http://blog.wilshipley.com/</a></span></a></span></span></strong></p>
<p>Jeff lamarche的博客:Jeff是MartianCraft的创始人,也是Beginning iOS Development系列书籍的作者之一。Jeff是一个非常博学的开发者。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://iphonedevelopment.blogspot.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://iphonedevelopment.blogspot.com/">http://iphonedevelopment.blogspot.com/</a></span></a></span></span></strong></p>
<p>Mike Ash的博客:博客中Mike收集了一些iOS相关的Q&A。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://www.mikeash.com/pyblog/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.mikeash.com/pyblog/">http://www.mikeash.com/pyblog/</a></span></a></span></span></strong></p>
<p>Joe Conway的博客:Jeo在Big Nerd Ranch带了很长时间,他的博客里面有许多有用的iOS/Cocoa代码和提示。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://stablekernel.com/blog/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://stablekernel.com/blog/">http://stablekernel.com/blog/</a></span></a></span></span></strong></p>
<p>objc.io:深度介绍iOS开发中的最佳实践经验和高级技术。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://www.objc.io/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://www.objc.io/">http://www.objc.io/</a></span></a></span></span></strong></p>
<p>iOS Developer Tips:2008年John Muchow就开始写这个博客了。这是第一批关于iPhone开发的博客。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://iosdevelopertips.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://iosdevelopertips.com/">http://iosdevelopertips.com/</a></span></a></span></span></strong></p>
<p>Gregory Hill的博客:里面有许多关于本地化处理的文章。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://blog.appliedis.com/author/gregory-hill/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://blog.appliedis.com/author/gregory-hill/">http://blog.appliedis.com/author/gregory-hill/</a></span></a></span></span></strong></p>
<p>iOS Dev Weekly:这是一些简讯集合的博客,由Dave Verwer负责,订阅之后,每周都会有更新,非常棒。<br/>
<strong><span style="text-decoration: underline;"><span style="color: #339966;"><a href="http://iosdevweekly.com/" target="_blank"><span style="color: #339966; text-decoration: underline;"><a href="http://iosdevweekly.com/">http://iosdevweekly.com/</a></span></a></span></span></strong></p>