We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
看了一下代码,认为有可以优化的地方,具体如下:
ZFSessionModel.h
calculateFileSizeInUnit
calculateUnit
ZFSessionModel.m
#define kZFGBSize (1024 * 1024 * 1024) #define kZFMBSize (1024 * 1024) + (float)calculateFileSizeInUnit:(unsigned long long)contentLength { if(contentLength >= kZFGBSize) { return (float) (contentLength / (float)kZFGBSize); } else if (contentLength >= kZFMBSize) { return (float) (contentLength / (float)kZFMBSize); } else if (contentLength >= 1024) { return (float) (contentLength / (float)1024); } else { return (float) (contentLength); } } + (NSString *)calculateUnit:(unsigned long long)contentLength { if(contentLength >= kZFGBSize) { return @"GB"; } else if(contentLength >= kZFMBSize) { return @"MB"; } else if(contentLength >= 1024) { return @"KB"; } else { return @"B"; } }
同时,个人认为DownloadState枚举最好更改为如下,以防止名称冲突:
DownloadState
typedef NS_ENUM(NSInteger, ZFDownloadState){ ZFDownloadStateStart = 0, /** 下载中 */ ZFDownloadStateSuspended, /** 下载暂停 */ ZFDownloadStateCompleted, /** 下载完成 */ ZFDownloadStateFailed /** 下载失败 */ };
The text was updated successfully, but these errors were encountered:
谢谢
Sorry, something went wrong.
No branches or pull requests
看了一下代码,认为有可以优化的地方,具体如下:
ZFSessionModel.h
中,calculateFileSizeInUnit
和calculateUnit
两个方法改成类方法ZFSessionModel.m
中,具体实现如下:同时,个人认为
DownloadState
枚举最好更改为如下,以防止名称冲突:The text was updated successfully, but these errors were encountered: