2024年最新iOS组件化方案-总结第一篇(2),2024年最新字节前端面试题

数据结构与算法

这一块在笔试、面试的代码题中考核较多,其中常考的数据结构主要有:数组、链表、队列、栈、Set、Map、哈希表等,不同数据结构有不同的方法以及储存原理,这些算是技术岗的必备知识。算法部分主要分为两大块,排序算法与一些其他算法题

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

排序算法根据考频高低主要有:快速排序、归并排序、堆排序、冒泡排序、插入排序、选择排序、希尔排序、桶排序、基数排序、Timsort这十种,这类考核点要么是算法的时间、空间复杂度、稳定度,要么是直接手写代码,故在理解算法原理的同时,对JS语言版的排序算法代码也要加强记忆。

  • 二叉树层序遍历
  • B 树的特性,B 树和 B+树的区别
  • 尾递归
  • 如何写一个大数阶乘?递归的方法会出现什么问题?
  • 把多维数组变成一维数组的方法
  • 知道的排序算法 说一下冒泡快排的原理
  • Heap 排序方法的原理?复杂度?
  • 几种常见的排序算法,手写
  • 数组的去重,尽可能写出多个方法
  • 如果有一个大的数组,都是整型,怎么找出最大的前 10 个数
  • 知道数据结构里面的常见的数据结构
  • 找出数组中第 k 大的数组出现多少次,比如数组【1,2, 4,4,3,5】第二大的数字是 4,出现两次,所以返回 2
  • 合并两个有序数组
  • 给一个数,去一个已经排好序的数组中寻找这个数的位 置(通过快速查找,二分查找)

@interface CRProtocolManager : NSObject

  • (void)registServiceProvide:(id)provide forProtocol:(Protocol*)protocol;

  • (id)serviceProvideForProtocol:(Protocol *)protocol;

@end

具体方法实现很简单可以参看Demo,我这里只是简单处理。

接下来就是要把项目提交到gitHub,做私有pod了

  • gitHub新建一个project名为CRProtocolManager

  • 终端cd至CRProtocolManager项目目录下执行命令git remote add origin https://github.com/sun6boys/CRProtocolManager.git

  • 因cocoaPods强制添加开源许可文件执行命令echo MIT>FILE_LICENSE创建名为FILE_LICENSE的文件

  • 终端cd至CRProtocolManager目录下执行命令pod spec create CRProtocolManager

  • 执行命令vim .CRProtocolManager.podspec编辑podspec文件,具体如何编辑可参看Demo中的podspec文件或者google

  • 退出编辑执行命令git add .

  • `git commit -m ‘log’

  • git tag 0.0.1 tag一定要和podspec中的version一致

  • git push origin master --tags --tags为了把刚才添加的tag提交上去

  • 执行命令pod repo push CRRepositories CRProtocolManager.podspec --verbose --allow-warnings 注:CRRepositories即为准备工作中的私有源仓库

  • 成功后pod search CRProtocolManager应该就能搜索到了

万里长征终于走完第一步,基础设施已经构建完毕

3.商品详情业务模块

既然组件化了,那我们所有的业务模块都是单独的project,但是这里我会分2个project,一个是商品详情业务入口模块,一个是商品详情业务模块。业务入口模块即是定义该模块对外提供业务接口的protocol,如果A模块需要调用到B模块,那A模块只需要引入CRProtocolManager和B模块的protocol,而不是引入整个B模块。

新建一个projectCRGoodsDetailServiceProtocol,创建一个和项目名一样的protocol文件,定义接口如下

@protocol CRGoodsDetailServiceProtocol

@required;

  • (UIViewController )goodsDetailViewControllerWithGoodsId:(NSString)goodsId goodsName:(NSString *)goodsName;

@end

参照CRProtocolManager做成私有pod

以上实施完毕,新建一个projectCRGoodsDetail,新建2个类

CRGoodsDetailServiceProvide

CRGoodsDetailViewController

CRGoodsDetailServiceProvide即是CRGoodsDetailServiceProtocol的实现者 所以他依赖

CRGoodsDetailServiceProtocol,因为商品详情模块需要跳转到订单确认页,所以他也依赖CRProtocolManager

添加Podfile文件编辑如下

source ‘https://github.com/sun6boys/CRRepositories.git’

source ‘https://github.com/CocoaPods/Specs.git’

target ‘CRGoodsDetail’ do

pod “CRProtocolManager”

pod “CRGoodsDetailServiceProtocol”

end

执行pod install --verbose --no-repo-update

最终CRGoodsDetailServiceProvide实现代码如下

#import “CRGoodsDetailServiceProvide.h”

#import <CRGoodsDetailServiceProtocol/CRGoodsDetailServiceProtocol.h>

#import <CRProtocolManager/CRProtocolManager.h>

#import “CRGoodsDetailViewController.h”

@interface CRGoodsDetailServiceProvide()

@end

@implementation CRGoodsDetailServiceProvide

  • (void)load

{

[CRProtocolManager registServiceProvide:[[self alloc] init] forProtocol:@protocol(CRGoodsDetailServiceProtocol)];

}

  • (UIViewController )goodsDetailViewControllerWithGoodsId:(NSString)goodsId goodsName:(NSString *)goodsName

{

CRGoodsDetailViewController *goodsDetailVC = [[CRGoodsDetailViewController alloc] initWithGoodsId:goodsId goodsName:goodsName];

return goodsDetailVC;

}

@end

CRGoodsDetailViewController实现代码如下

#import “CRGoodsDetailViewController.h”

@interface CRGoodsDetailViewController ()

@property (nonatomic, copy) NSString *goodsId;

@property (nonatomic, copy) NSString *goodsName;

@property (nonatomic, strong) UILabel *statusLabel;

@property (nonatomic, strong) UIButton *buyButton;

@end

@implementation CRGoodsDetailViewController

  • (instancetype)initWithGoodsId:(NSString *)goodsId goodsName:(NSString *)goodsName

{

self = [super init];

if (self) {

_goodsId = goodsId;

_goodsName = goodsName;

}

return self;

}

  • (void)viewDidLoad {

[super viewDidLoad];

self.navigationItem.title = self.title;

[self.view addSubview:self.statusLabel];

[self.view addSubview:self.buyButton];

}

  • (void)viewWillLayoutSubviews

{

[super viewWillLayoutSubviews];

self.statusLabel.frame = CGRectMake(0, 0, 100, 20);

self.statusLabel.center = self.view.center;

self.buyButton.frame = CGRectMake(0, self.view.frame.size.height - 45, self.view.frame.size.width, 45);

}

#pragma mark - event

  • (void)didClickBuyButton:(UIButton *)button

{

}

#pragma mark - getters

  • (UILabel *)statusLabel

{

if (_statusLabel == nil) {

_statusLabel = [[UILabel alloc] init];

_statusLabel.textColor = [UIColor redColor];

_statusLabel.font = [UIFont systemFontOfSize:15.f];

_statusLabel.textAlignment = NSTextAlignmentCenter;

_statusLabel.text = @“暂未购买”;

}

return _statusLabel;

}

  • (UIButton *)buyButton

{

最后

正值招聘旺季,很多小伙伴都询问我有没有前端方面的面试题!

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

前端资料图.PNG

Size:15.f];

_statusLabel.textAlignment = NSTextAlignmentCenter;

_statusLabel.text = @“暂未购买”;

}

return _statusLabel;

}

  • (UIButton *)buyButton

{

最后

正值招聘旺季,很多小伙伴都询问我有没有前端方面的面试题!

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

[外链图片转存中…(img-qy2P1iZ7-1715698926767)]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值