組件化
如今實現(xiàn)的方案
業(yè)務(wù)業(yè)務(wù)之間溝通
解決業(yè)務(wù)與業(yè)務(wù)之間頁面跳轉(zhuǎn),
路由,或者業(yè)務(wù)manger的別名-
解決業(yè)務(wù)與業(yè)務(wù)之后cellview展示的穿插
1.cell數(shù)據(jù)實現(xiàn)統(tǒng)一刷新接口,data建議統(tǒng)一字典類型,內(nèi)部在使用時,自己做對應(yīng)的數(shù)據(jù)轉(zhuǎn)化,模型及其它- (void)xhl_refreshData:(id _Nonnull )data;
2.自己實現(xiàn)一個manger管理cell如下的方法 然后返回統(tǒng)一的接口
//需要根據(jù)數(shù)據(jù)做一個展示,請返回我cell名字,高度,以及data模型,情在cell中 - (void)xhl_refreshData:(id _Nonnull )data; 方法中實現(xiàn)自己的數(shù)據(jù)解析,data就是你傳入的數(shù)據(jù) + (XhlItemModel *)xhl_newsCellData:(NSDictionary *)dict; //需要在新聞列表展示的類型cell + (NSArray *)xhl_newsRegisterClass;
3.點擊事件處理統(tǒng)一走路由的XhlMail://newDatil
4.列表可以實現(xiàn),模型套模型的方案實現(xiàn)展示,模型中data,就是自己的data,cell高度,是自己模型中計算好了,給展示模型,cell名字可以根據(jù)不同類型進(jìn)行配置
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ return self.dataArry.count; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return self.dataArry[section].count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ CQItemModel *model = self.dataArry[indexPath.section][indexPath.row]; UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:model.cellName forIndexPath:indexPath]; [cell cq_refreshData:model.data]; return cell; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ CQItemModel *model = self.dataArry[indexPath.section][indexPath.row]; return model.sizeForItem; } - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ CQItemModel *model = self.dataArry[section].firstObject; return model.insetForSection; } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{ CQItemModel *model = self.dataArry[section].firstObject; return model.minimumLineSpacing; } //區(qū)頭高度 - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{ CQItemModel *model = self.dataArry[section].firstObject; return model.footViewSize; } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{ CQItemModel *model = self.dataArry[section].firstObject; return model.minimumInteritemSpacing; }
數(shù)據(jù)組裝
CQItemModel *topUp = [[CQItemModel alloc] init];
topUp.cellName = @"CQDgShopRecCell";
topUp.sizeForItem = CGSizeMake((SCREEN_WIDTH)/2, height);
topUp.footViewSize = CGSizeMake(SCREEN_WIDTH, 15);
for (CQDgHomeConfigModel *model in self.configArry) {
if ([model.type isEqualToString:@"5"]) {
topUp.data = model;
break;
}
}
[self.dataArry addObject:@[wishTree,topUp]];
- 業(yè)務(wù)與業(yè)務(wù)之間網(wǎng)絡(luò)地址,appId通信
每個業(yè)務(wù)配置一套屬于自己的網(wǎng)絡(luò)地址,和appId蘸秘、host
在業(yè)務(wù)通過路由調(diào)用自己時,實現(xiàn)網(wǎng)絡(luò)地址和appId切換,沒有默認(rèn)app全局設(shè)置
app與業(yè)務(wù)之間的溝通
- 業(yè)務(wù)適配app(顏色,UI,數(shù)據(jù),圖片,網(wǎng)絡(luò)地址)
- 溝通方式
1.直接導(dǎo)入頭文件,業(yè)務(wù)的manger
2.也可以通過manger的別名使用
業(yè)務(wù)manger的別名處理方案
所有的manger寫的都是類方法,或者單例方法,可以通過導(dǎo)入manger的頭文件方式之間使用,由于,業(yè)務(wù)業(yè)務(wù)之間溝通導(dǎo)入頭文件.,那么必然會有m,文件關(guān)聯(lián),m文件會有業(yè)務(wù)關(guān)聯(lián),有可能在自己做的業(yè)務(wù)中沒有這個業(yè)務(wù).那么就沒法使用了.
那么不導(dǎo)入頭文件,就可以導(dǎo)入一個api文件,不存在m文件,這樣一個文件,協(xié)議可以實現(xiàn).只有方法名,沒有實現(xiàn)文件.
/*
* 賬號協(xié)議,該協(xié)議只在內(nèi)部調(diào)用
*/
@protocol XHLLoginProtocol <XHLBaseProtocol>
@optional
/**
* @brief 調(diào)用登錄接口
* @param loginCompletionBlock 不能設(shè)置為nil 登錄成功、失斃ぜ臁(退出登錄頁面)的回調(diào)凡泣,參數(shù)YES:登錄成功物延,NO:登錄失敗或者未登錄直接退出登錄頁面谜疤;必須要調(diào)用选脊,不然會導(dǎo)致再次登錄無法調(diào)起
*/
+ (void)xhlLogin:(void (^)(BOOL success))loginCompletionBlock;
//退出登錄
+ (void)logout;
/**
登錄成功通知回調(diào)
*/
+ (NSString *)notificationLoginSuccess;
/**
登錄狀態(tài)變化通知回調(diào)
*/
+ (NSString *)notificationLoginStateChange;
/**
退出登錄成功通知回調(diào)
*/
+ (NSString *)notificationLogout;
@end
如過通過這個協(xié)議文文件找到一個實現(xiàn)文件的類,那么就可以調(diào)用.
XhlPyramid 實現(xiàn)了這個方案
首先給XhlPyramid聲明一個分類,然后里面實現(xiàn)一個查找自己實現(xiàn)類的方法,方便使用XhlPyramid打點調(diào)用
然后對實現(xiàn)類進(jìn)行注冊,關(guān)聯(lián)協(xié)議類,和實現(xiàn)類
[XhlPyramid registerService:XHLLoginProtocol implClass:XhlLoginManger];\協(xié)議管理實現(xiàn)類
[XhlPyramid registerAlias:@selector(Alias) forService:XHLLoginProtocol];\協(xié)議管理別名
內(nèi)部是使用的一個字典來關(guān)聯(lián)
//別名關(guān)聯(lián)協(xié)議字典
當(dāng)你使用,XhlPyramid.Logind的時候,+ (Class<XHLLoginProtocol>)xhl_login;不存在,內(nèi)部使用消息轉(zhuǎn)發(fā)機(jī)制,為他添加一個方法,實現(xiàn)查找,在已經(jīng)存好的字典中進(jìn)行查找,最后返回一個對象
存在問題
協(xié)議中間調(diào)度器,是不支持,一個協(xié)議關(guān)聯(lián)多個類,還是我沒有研究透,
別名管理協(xié)議,在協(xié)議中就可以實現(xiàn),為什么還要,在實現(xiàn)類中實現(xiàn)