-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
864 lines (352 loc) · 33.4 KB
/
index.html
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
<!doctype html>
<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />
<meta name="keywords" content="Hexo, NexT" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />
<meta name="description" content="享受自由自在的编码生活,享受科技改变生活!">
<meta property="og:type" content="website">
<meta property="og:title" content="CoderRyanの博客">
<meta property="og:url" content="https://github.com/Ryan0520/Ryan0520.github.io/index.html">
<meta property="og:site_name" content="CoderRyanの博客">
<meta property="og:description" content="享受自由自在的编码生活,享受科技改变生活!">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="CoderRyanの博客">
<meta name="twitter:description" content="享受自由自在的编码生活,享受科技改变生活!">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Muse',
sidebar: {"position":"left","display":"post"},
fancybox: true,
motion: true,
duoshuo: {
userId: '0',
author: '博主'
},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<link rel="canonical" href="https://github.com/Ryan0520/Ryan0520.github.io/"/>
<title> CoderRyanの博客 </title>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
<div class="container one-collumn sidebar-position-left
page-home
">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">CoderRyanの博客</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle"></p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />
首页
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
归档
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
标签
</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="https://github.com/Ryan0520/Ryan0520.github.io/2017/01/16/iOS-design-mode-adapter/">
<span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Ryan.Shen">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="CoderRyanの博客">
<span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
<img style="display:none;" itemprop="url image" alt="CoderRyanの博客" src="">
</span>
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/01/16/iOS-design-mode-adapter/" itemprop="url">
学习iOS设计模式第一章 适配器(Adapter)
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-16T17:49:26+08:00">
2017-01-16
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>今天学习了iOS设计模式中的适配器模式,适配器有两种模式<br><strong>对象适配器模式</strong><br>– 在这种适配器模式中,适配器容纳一个它包裹的类的实例。在这种情况下,适配器调用被包裹对象的物理实体。<br><strong>类适配器模式</strong><br>– 这种适配器模式下,适配器继承自已实现的类(一般多重继承)。<br>现在以一个例子来说明这种适配器的使用,首先在你的UI控件头文件里声明你需要用来适配的方法</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">- (void)loadData:(id <BusinessCardAdapterProtocol>)data;</div></pre></td></tr></table></figure>
<p>再到你的UI控件.m里面实现相应控件的属性赋值,然后新建一个<code>BusinessCardAdapterProtocol</code>协议,假如UI控件的需要外界设置下面这三种属性</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">@property (nonatomic, copy) NSString *name;</div><div class="line">@property (nonatomic, copy) NSString *phoneNumber;</div><div class="line">@property (nonatomic, strong) UIColor *lineColor;</div></pre></td></tr></table></figure>
<p>则在<code>BusinessCardAdapterProtocol</code>协议里面声明</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">- (NSString *)name; </div><div class="line">- (UIColor *)lineColor; </div><div class="line">- (NSString *)phoneNumber;</div></pre></td></tr></table></figure>
<p>方法供实现,接下来再创建一个基本的适配器类<code>BusinessCardAdapter</code>,遵守<code>BusinessCardAdapterProtocol</code>协议,并在头文件里声明一个属性和一个构造方法</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">@property (nonatomic, weak) id data; // 输入对象 </div><div class="line"></div><div class="line">- (instancetype)initWithData:(id)data; // 与输入对象建立联系</div></pre></td></tr></table></figure>
<p>在.m文件中实现如下代码</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">- (instancetype)initWithData:(id)data{</div><div class="line"> self = [super init];</div><div class="line"> if (self) {</div><div class="line"> self.data = data;</div><div class="line"> }</div><div class="line"> return self;</div><div class="line">}</div><div class="line">- (NSString *)name{</div><div class="line"> </div><div class="line"> return nil;</div><div class="line">}</div><div class="line">- (NSString *)phoneNumber{</div><div class="line"> return nil;</div><div class="line">}</div><div class="line">- (UIColor *)lineColor{</div><div class="line"> return nil;</div><div class="line">}</div></pre></td></tr></table></figure>
<p>现在新建一个模型文件叫作<code>Model</code>,属性如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">@property (nonatomic, copy) NSString *name;</div><div class="line">@property (nonatomic, copy) NSString *phoneNumber;</div><div class="line">@property (nonatomic, strong) UIColor *lineColor;</div></pre></td></tr></table></figure>
<p>再创建一个用来适配Model类的适配器<code>ModelAdapter</code>继承自基类适配器<code>BusinessCardAdapter</code>,在.m文件里重载父类的方法如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div></pre></td><td class="code"><pre><div class="line">#import "Model.h"</div><div class="line">#import "ModelAdapter.h"</div><div class="line"></div><div class="line">@implementation ModelAdapter</div><div class="line"></div><div class="line">- (instancetype)initWithData:(id)data{</div><div class="line"> self = [super init];</div><div class="line"> if (self) {</div><div class="line"> self.data = data;</div><div class="line"> }</div><div class="line"> return self;</div><div class="line">}</div><div class="line"></div><div class="line">- (NSString *)name{</div><div class="line"> Model *data = self.data;</div><div class="line"> return data.name;</div><div class="line">}</div><div class="line"></div><div class="line">- (UIColor *)lineColor{</div><div class="line"> Model *data = self.data;</div><div class="line"> return data.lineColor;</div><div class="line">}</div><div class="line"></div><div class="line">- (NSString *)phoneNumber{</div><div class="line"> Model *data = self.data;</div><div class="line"> return data.phoneNumber;</div><div class="line">}</div><div class="line"></div><div class="line">@end</div></pre></td></tr></table></figure>
<p>这时候在我们的<code>ViewController</code>里面这样使用</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">// 创建UI控件</div><div class="line">BusinessCardView *cardView = [[BusinessCardView alloc] initWithFrame:BUSINESS_FRAME]; cardView.center = self.view.center;</div><div class="line">[self.view addSubview:cardView];</div><div class="line">// 初始化模型 </div><div class="line">Model *model = [[Model alloc] init];</div><div class="line">model.name = @"CoderRyan";</div><div class="line">model.phoneNumber = @"188 - 8848 - 8848";</div><div class="line">model.lineColor = [UIColor redColor];</div><div class="line">// 与适配器连接</div><div class="line">BusinessCardAdapter *adapter = [[ModelAdapter alloc] initWithData:model];</div><div class="line">[cardView loadData:adapter];</div></pre></td></tr></table></figure>
<p>cmd+R运行,效果图如下</p>
<p><img src="1.png" alt="1.png"></p>
<p>假如现在有另外一个Model,需要适配,新建一个<code>NewModel</code>类,包含如下属性</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">#import <Foundation/Foundation.h></div><div class="line"></div><div class="line">@interface NewModel : NSObject</div><div class="line"></div><div class="line">@property (nonatomic, copy) NSString *name;</div><div class="line"></div><div class="line">@property (nonatomic, copy) NSString *hexColorString;</div><div class="line"></div><div class="line">@property (nonatomic, copy) NSString *phoneNumber;</div><div class="line">@end</div></pre></td></tr></table></figure>
<p>这时候,同样只需要新建一个继承自基类适配器<code>BusinessCardAdapter</code>,在.m文件里重载父类的方法如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div></pre></td><td class="code"><pre><div class="line">#import "NewCardModelAdapter.h"</div><div class="line">#import "NewModel.h"</div><div class="line">@implementation NewCardModelAdapter</div><div class="line"></div><div class="line">- (instancetype)initWithData:(id)data</div><div class="line">{</div><div class="line"> self = [super init];</div><div class="line"> if (self) {</div><div class="line"> self.data = data;</div><div class="line"> }</div><div class="line"> return self;</div><div class="line">}</div><div class="line"></div><div class="line">- (NSString *)name{</div><div class="line"> NewModel *model = self.data;</div><div class="line"> return model.name;</div><div class="line">}</div><div class="line"></div><div class="line">- (NSString *)phoneNumber{</div><div class="line"> NewModel *model = self.data;</div><div class="line"> return model.phoneNumber;</div><div class="line">}</div><div class="line"></div><div class="line">- (UIColor *)lineColor{</div><div class="line"> NewModel *model = self.data;</div><div class="line"> // TODO</div><div class="line"> if ([model.hexColorString isEqualToString:@"black"]) {</div><div class="line"> return [UIColor blackColor];</div><div class="line"> } else {</div><div class="line"> return [UIColor redColor];</div><div class="line"> }</div><div class="line">}</div><div class="line"></div><div class="line">@end</div></pre></td></tr></table></figure>
<p>如果这时候想要在VC里面用新的适配器,只需要</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">// 与适配器连接</div><div class="line">Model *model = [[Model alloc] init];</div><div class="line">model.name = @"CoderRyan";</div><div class="line">model.phoneNumber = @"188 - 8848 - 8848";</div><div class="line">model.lineColor = [UIColor redColor];</div><div class="line"></div><div class="line">BusinessCardAdapter *adapter = [[ModelAdapter alloc] initWithData:model];</div><div class="line">[cardView loadData:adapter];</div></pre></td></tr></table></figure>
<p>更改成</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">NewModel *newModel = [[NewModel alloc] init];</div><div class="line">newModel.name = @"CoderRyan";</div><div class="line">newModel.phoneNumber = @"188 - 8848 -8848";</div><div class="line">newModel.hexColorString = @"black";</div><div class="line"></div><div class="line">BusinessCardAdapter *adapter = [[NewCardModelAdapter alloc] initWithData:newModel];</div><div class="line">[cardView loadData:adapter];</div></pre></td></tr></table></figure>
<p>即可.<br>总结来说,就是在UI控件外部提供一个方法传入实现了协议的属性,外部根据一个模型来创建一个适配器,再通过与适配器连接.进行更新UI.<br>优点:耦合度低,可以扩展多种适配的样式<br>缺点:代码量多,文件多.对于新手可能不理解这种好处.<br>以上是我对适配器模式的大致了解,上面的Demo是用极客学院的例子.如果有错漏之处,希望可以给我在下面评论留言给我指出,谢谢~</p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="https://github.com/Ryan0520/Ryan0520.github.io/2017/01/16/upload-cocoapods/">
<span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Ryan.Shen">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="CoderRyanの博客">
<span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
<img style="display:none;" itemprop="url image" alt="CoderRyanの博客" src="">
</span>
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/01/16/upload-cocoapods/" itemprop="url">
上传代码到Cocoapod需要注意的地方
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-16T17:35:30+08:00">
2017-01-16
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="上传代码到Cocoapod需要注意的地方"><a href="#上传代码到Cocoapod需要注意的地方" class="headerlink" title="上传代码到Cocoapod需要注意的地方"></a>上传代码到Cocoapod需要注意的地方</h1><blockquote>
<p>上传主要步骤可以参照这篇<a href="http://www.jianshu.com/p/1db5cb08e35c" target="_blank" rel="external">【最新】上传代码到cocoapod</a></p>
</blockquote>
<p>本文主要是用来以防以后想要上传自己写好的代码到Cocoapod供别人使用遇到的一些问题,主要问题是处在pod spec lint xxx.podspec 文件不通过。会报错,这时候要看清楚报错的内容。下面是容易犯错的地方</p>
<p>1.在填写podspec文件的时候,将value值的英文双引号写成中文的双引号。就算你从别的地方复制过来是双引号,由于mac系统默认的设置都会自动地转成中文的双引号。可以在设置->键盘->文本->右边的双引号样式和单引号样式选择最后一个就可以了。</p>
<p>2.有的时候虽然你在你自己的代码工程里面编译通过没问题,但是你pod spec lint 检测的时候都会通不过,原因是因为你的工程里面代码文件有警告,例如你将一个参数原本是填YES/NO的,你填成了nil,在工程里面虽然不报错,能编译过,但是你检测的时候是不过的。不过这种警告都会列出来,你可以很清楚的知道在哪个类的哪一行出现这种错误,修改过来就可以了。</p>
<p>3.有时候你假如在你的工程文件里面引用了第三方框架的东西,例如你import \<afnetworking.h\>,会检测不通过,她说AFNetworking.h file not found.use “quote” 。这句话好像是说找不到\<afnetworking.h\>文件,叫你换成 “AFNetworking.h”就可以编译通过了.</afnetworking.h\></afnetworking.h\></p>
<p>4.检测你的podspec时候,如果直接用pod spec lint xxx.podspec的话,出现错误的话它只会直接一句红色的话<code>The spec did not pass validation, due to 1 error.</code>告诉你的有多少个error和warning,而不会具体的指出你的错误出在哪里,这时候你可以在这句指令后面加上参数–verbose 这样就会告诉你具体的错误信息。这样根据它提示你的错误信息去解决就可以了。</p>
<p>5.每次修改成功之后,记得要更改podspec里面的version版本。而且需要你在git里面打个tag,这个tag可以对应于这个版本号。具体如何打tag可以参考一下最上面给出的文章。有可能会检测出错提醒你例如下图的错误。因为没有这条分支,所以你clone不下来。这时候在git里面创建这条分支,推上去就可以了。</p>
<p><img src="/images/upload_cocoapods_1.png" alt="1"></p>
<p>编译成功的时候,会变成下面这个样子,然后你执行pod trunk push xxx.podspec 指令,稍等片刻,完成之后你在pod search xxx(你的podspec里面的s.name),成功之后就会出现到你的个人pod了,然后就可以给别人用,是不是很方便?平时的项目代码收集的好东西,赶紧封装成一个自己的库,然后弄上pod上面去和别人分享吧,让别人看你的代码,指出代码问题所在,这样才能促进自己的水平!</p>
<p><img src="/images/upload_cocoapods_2.png" alt="2"></p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="https://github.com/Ryan0520/Ryan0520.github.io/2017/01/16/hello-world/">
<span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Ryan.Shen">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="CoderRyanの博客">
<span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
<img style="display:none;" itemprop="url image" alt="CoderRyanの博客" src="">
</span>
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/01/16/hello-world/" itemprop="url">
Hello World
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-16T16:17:16+08:00">
2017-01-16
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>Welcome to <a href="https://hexo.io/" target="_blank" rel="external">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="external">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="external">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo new <span class="string">"My New Post"</span></div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="external">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo server</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="external">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo generate</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="external">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo deploy</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="external">Deployment</a></p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</section>
</div>
</div>
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
</div>
</div>
<aside id="sidebar" class="sidebar">
<div class="sidebar-inner">
<section class="site-overview sidebar-panel sidebar-panel-active">
<div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image"
src="/images/avatar.jpg"
alt="Ryan.Shen" />
<p class="site-author-name" itemprop="name">Ryan.Shen</p>
<p class="site-description motion-element" itemprop="description">享受自由自在的编码生活,享受科技改变生活!</p>
</div>
<nav class="site-state motion-element">
<div class="site-state-item site-state-posts">
<a href="/archives">
<span class="site-state-item-count">3</span>
<span class="site-state-item-name">日志</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags">
<span class="site-state-item-count">2</span>
<span class="site-state-item-name">标签</span>
</a>
</div>
</nav>
<div class="links-of-author motion-element">
</div>
</section>
</div>
</aside>
</div>
</main>
<footer id="footer" class="footer">
<div class="footer-inner">
<div class="copyright" >
©
<span itemprop="copyrightYear">2017</span>
<span class="with-love">
<i class="fa fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">Ryan.Shen</span>
</div>
<div class="powered-by">
由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>
<div class="theme-info">
主题 -
<a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
NexT.Muse
</a>
</div>
</div>
</footer>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
</div>
</div>
<script type="text/javascript">
if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
window.Promise = null;
}
</script>
<script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
<script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
<script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
<script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
<script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>
</body>
</html>